Explain what static meansdoes in JavaSolutionThe static keyw
Explain what static means/does in Java.
Solution
The static keyword denotes that a member variable or method can be accessed without requiring an instantiation of the class to which it belongs. In simple terms we can say that we can call method even if no object is created.
We can use static keyword in below cases:
1. Class variables
2. Class methods
3. Block
4. Nested class
The above can be described more below:
1. Static variable can be used to refer commom property of all objects. Example : static string college =\"itc\";
2. Static method : belongs to class rather than object.
Example: static void change(){
College=\"BBB\";
}
3. Static block: is used to initalize the static data member. It is executed before main method at the time of classloading.
