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

 
 

Share on Google+Share on Google+
SCJP Module-3 Question-8
Posted on: July 12, 2010 at 12:00 AM
Advertisement
The Program given below will test your knowledge of Inner classes and Outer classes in Java and help you for preparation of SCJP examination.

Given below the sample code :

class OuterClass{
String s = "OuterClass ";

public static void main(String[] args) {
new OuterClass().new InnerClass();
}

OuterClass() {
System.out.print(s);
}

class InnerClass {
String s = "InnerClass";

InnerClass() {
System.out.print(s);
}
}
}

What will be the output of the following code ?

1.  It will give compile error.

2. Prints : OuterClass InnerClass

3. Prints : OuterClass

4. Prints : InnerClass

Answer :

(2)

Advertisement

Related Tags for SCJP Module-3 Question-8:


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