What it means that method or field is static

What it means that method or field is static

Answer :

Below are meaning if method declare static:

  • 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 meaning if field declare static:

  • static method belongs to the class
  • Static member that will be used Independently of any object of that class
  • Static member can be used by itself, without reference to a specific instance
  • When a member is declared static, it can be accessed before any objects of its class are created
  • Instance variables declared as static are, essentially, global variables

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *