Question: Consider the following code fragment public class A { public void m1() { System.out.println(m1); public void m2() { System.out.println(m2); public static void main (String[]

Consider the following code fragment public class A { public void m1() { System.out.println (

Consider the following code fragment public class A { public void m1() { System.out.println("m1"); public void m2() { System.out.println("m2"); public static void main (String[] args) { } m1(); // Line 1 m2(); // Line 2 } Which lines have compilation errors? (3 marks) Consider the following Java class public class B { public static int x; public int y; public B() { x = 0; y = -1; } public void inc() { } ++X; ++y; } } } and the following code fragment B ref1 = new B(); B ref2 new B(); refl. inc(); ref2.inc(); Which values do ref2.x and ref 2. y have after executing this code? new Mac p

Step by Step Solution

3.28 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets analyze the provided code fragments First Code Fragment java public class A public void m1 Syst... 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!