In most of the cases, the interviewer asks the difference between static and final keywords. So what exactly the difference is in static and final. Following terms are given below, according to this term both are differentiated. Sometimes it's confusion, what exactly the difference between static and final? sometimes most of the method prefer both Static and final to be and Once we do that, then this is the constant in Java.
 |
Comparison between static and final |
Static In Java
Features |
Static |
Applicable |
Static is applicable to the nested static class, variables, methods, and blocks |
Initialization |
It is not compulsory to initialize the static variable at the time of its declaration |
Modification |
The static variable can be reinitialized |
Methods |
A static method can only access the static member of the class and can only be called by other static methods |
Class |
A static class object cannot be created and it only contains static member |
Block |
Static block is used to initialize the static variable |
Social Plugin