Question: What is the output of the following Java program? public class MyClass { int a, b; MyClass() { a = 1; b = 2;

What is the output of the following Java program? public class MyClass 

What is the output of the following Java program? public class MyClass { int a, b; MyClass() { a = 1; b = 2; } 10 2 15 16 17 public void print(){ } System.out.println(a + " + b); public static void main(String[] args) { MyClass x = new MyClass(); MyClass y = x; x. a++; x.b++; y.print(); 18 19 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Title Find output Output The outp... View full answer

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!