Question: Can you invoke an instance method or reference an instance variable from a static method? Can you invoke a static method or reference a static
Can you invoke an instance method or reference an instance variable from a static method? Can you invoke a static method or reference a static variable from an instance method? What is wrong in the following code? (Working With Java )
Also, I looked at the book, it says one thing and one expert answer on Chegg said something different. Look at both pictures please.
Expert Answer below.

Book explanation below

Program Below:
1 public class C { 2 public static void main(String[] args) { 3 method1(); 4 } 5 6 public void method1() { 7 method2(); 8 } 9 10 public static void method2() { 11 System.out.println("What is radius " + c.getRadius()); 12 } 13 14 Circle c = new Circle(); 15 }
Anonymous answered this 5,219 answers Was this answer helpful? | 0 (A) No, we can't invoke an instance method from a static method. We can only invoke a static method from a static method. (B) No, we can't invoke a static method from an instance method. We can only invoke an instancemethod from an instancemethod. method1() is an instance method, but it is being called from the main) method whichis a static method. So, it will show error as we can't invoke an instance method from a static method. Also, method20) is a static method, but method1(0 is an instance method. So, we can't invoke a static method from an instance method. Comment>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
