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 @$20 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

Download Projects

Google Advertisements


Buy Websites 9999595223

Buy Fresh and Payment Receive Media.net Account with Website. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs