What is the difference between static and instance methods?

What is the difference between static and instance methods?

  • Instance method belongs to the instance of a class therefore it requires an instance before it can be invoked, whereas static method belongs to the class itself and not to any class instance so it doesn’t need an instance to be invoked.
  • Instance methods use dynamic (late) binding, whereas static methods use static (early) binding.
  • When the JVM invokes a class instance method, it selects the method to invoke based on the type of the object reference, which is always known at run-time. On the other hand, when the JVM invokes a static method, it selects the method to invoke based on the actual class of the object, which may only be known at compile time.

Leave a Reply