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

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

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

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