+1 vote
in JAVA by
What is the difference between static (class) method and instance method?

1 Answer

0 votes
by

static or class method instance method

1)A method that is declared as static is known as the static method. A method that is not declared as static is known as the instance method.

2)We don't need to create the objects to call the static methods. The object is required to call the instance methods.

3)Non-static (instance) members cannot be accessed in the 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 n*n*n;} For example: public void msg(){...}.

Related questions

+1 vote
asked Jan 27, 2020 in JAVA by rahuljain1
0 votes
asked Jun 16, 2019 in JAVA by reins.robin
...