What is static keyword in Java?



Suraj Said

+0 -0

i) A static field is shared by all instances of a class, and there is only one copy of a static field regardless of how many instances of the class are created.
ii) A static method can be called directly on the class, rather than on an instance of the class.
iii) A static block of code is executed when a class is first loaded by the JVM before any objects are created. It's commonly used for initializing static fields.
iv) A static nested class is a class that is defined inside another class, but it does not have access to non-static members of the outer class.



Submit Your Response