Home Tutorial Java Scjp Part3 SCJP Module-3 Question-9

 
 

Share on Google+Share on Google+
SCJP Module-3 Question-9
Posted on: July 12, 2010 at 12:00 AM
Advertisement
The given program will test your knowledge of Inheritance in Java programming and It is also very helpful for SCJP examination.

Given below the sample code :

class SuperClass {
String s = "Outer";

public static void main(String[] args) {
M2 m2 = new M2();
m2.display();
}
}

class M1 {
String s = "M1";

void display() {
System.out.println(s);
}
}

class M2 extends M1 {
String s = "M2";
}

What will be the output of the following code ?

1. Compile error

2. M1

3  M2

4. M1 M2.

Answer :

(2)

Advertisement

Related Tags for SCJP Module-3 Question-9:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 12, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com