Static Keyword Interview Questions in Java

Google Advertisements

Prev Tutorial Next Tutorial

Interview Questions on Static Keyword in Java

.

What is static keyword in java ?

Static keyword in java are used for memory management

Why we use static keyword in java ?

Static keyword is mainly used for memory management.

What is static variable in java

Variables declared with static keyword is known as static variables.

What is static variable in java? ?

Variables declared with static keyword is known as static variables. If we change any static variable value using a particular object then its value changed for all objects means it is common to every object of that class. This type of variable is class level.

What is static method in java ?

Method which is preceded with static keyword is know as static method. JVM will not call these static methods automatically you need to call these static methods from main method or static block or variable initialization. These types of method called by using class name itself no need to create object.

Note: Only Main method will b called by JVM automatically.

Example

static void show()
{
......
......
}

What is static block in Java ?

Static blocks are the blocks which will have braces and with static keyword and these block execute at the time of class loading.

Example

static
{ 
......
......
 }

What is the need of static block ?

Static blocks will be executed at the time of class loading. If you want to execute any logic before main method loading you should go with static block.

Why main method is static in java ?

To execute main method without creating object.

.Can we overload static methods in java ?

Yes

Can we override static methods in java ?

No

Can we write static public void main(String [] args) ?

Yes, Order of modifiers can change.


Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. If you want to post your article on our website/FB Group/FB Page please contact on hitesh.xc@gmail.com or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders. Difference between path and classpath in Java

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs