What restriction placed on static method or static block
Answer:
Below are restriction placed on static method:
- static method can not be overridden
- Object variable inside static method not accessible
- They can only call other static methods.
- They must only access static data.
- They cannot refer to this or super in any way.
- They can be accessed directly using class and don’t instance of class to access it
Below are restriction placed on static block:
- Object variable inside static method not accessible
- They can only call other static methods.
- They must only access static data.
- They cannot refer to this or super in any way.