Question: 1. Consider the following class: public class MC { public int x; public static int y; public MC () {x=1; y += 4; } public

 1. Consider the following class: public class MC { public int

1. Consider the following class: public class MC { public int x; public static int y; public MC () {x=1; y += 4; } public MC (int v) { this.set (v+2); y++; } public void set (int v) {this.x = v;} public MC inc() { x++; y++; return this; } What is the output of the following code segments? MC mc1 = new MC (8); 1 7 MC mc2 new MC () ; mc1 = mc2.inc(); System.out.println(mcl.x + " "+mc2.x); // output 1 System.out.println (mc1.y + "+mc2.y); // output 2 mcl = new MC (4); System.out.println (mc1.x + " "+mc2.x); // output 3 System.out.println(mcl.y + " "+c2.y); // output 4 mc2.set (9) ; System.out.println(mc1.x + " "+mc2.x); // output 5 System.out.println(mcl.y + " "+mc2.y); // output 6 mcl = new MC () ; "+mc2.x); // output 7 System.out.println(mc1.x + " System.out.println(mcl.y + "+mc2.y); // output 8 System.out.println (MC.y); // output 9 IT

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 Databases Questions!