We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 1
619728, 7:20 AM 25-May-2022.9n9
{Undevtnding static Keyword state Keyword is muinley used for Memory Management statig
Stale Variable
1) A variable whichis declared inside a clas outside any method ora block ora constructor
with the help of static keyword is known as stati varia
2) static variable will be initialized at the time of class loading.
3) We can access a static variable in three ways by using class object, by using identifier name, by using class name.
4) For final statie variables, JVM will not provide any default values. Itis the responsibilty of the programmer to initilze then
5) There will be only one copy of static variable available through out the program,
6) A statie variable ean NEVER be LOCAL variable.
‘static Method
1) A method which is declared as state with static keyword is known as static method.
2) We can access a static method in 3 ways, by using identifier Name, by using ClassObject & by using ClassName
3) We ean aecess an NON-STATIC variable inside an static method with the help of CLASS-OBJECT
state Block
Variable Method Block
1) Ina Java program if we are having a main() and a static block the first priority will be given to the static block.
2) statie block will be executed even before main().
3) We can write any number of static blocks in our program, they will be getting executed in that defined order.
4) We cannot call the static blocks.
5) If we want to RUN our program writing main( is mandatory. [Only by writing static block we cant run our program]
-nps:iflassroom google.com/eINDKONT&zMze20DIW?pli=t uw