Java Interview Questions


Q:

Is it possible to access non-static method from a static method

 
A: No static method can not access non-static methods
Java has two types of methods, instance methods and static methods. A static method can be accessed without creating an instance of the class. If you try to use a non-static method and variable defined in this class then the compiler will say that non-static variable or method cannot be referenced from a static context. Static method can call only other static methods and static variables defined in the class.
.

Java Interview Questions