ProAnswers.org

What is difference between static (class) method and instance method?

1)A method i.e. declared as static is known as static method. A method i.e. not declared as static is known as instance method.

2)Object is not required to call static method. Object is required to call instance methods.

3)Non-static (instance) members cannot be accessed in static context (static method, static block and static nested class) directly. static and non-static variables both can be accessed in instance methods.

4)For example: public static int cube(int n){ return nnn;}

For example: public void msg(){...}.