Question: 11. Consider the following Java class: public class MyClass{ private int x - 4; public MyClass() { x = 5; } public void myMethod

  • 11. Consider the following Java class: public class MyClass{ private int x 


11. Consider the following Java class: public class MyClass{ private int x - 4; public MyClass() { x = 5; } public void myMethod (int y) { x++; if (y > 0) { int x = 6; switch (y) { case 3: x = 3; case 4: x-6; x++; break; case 5: x = 2; default: x++; break; System.out.print (x); } } System.out.println(x); What gets printed if we instantiate MyClass and then call myMethod (4) on the new instance?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!