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

 
 

SCJP Module-3 Question-8
Posted on: July 12, 2010 at 12:00 AM
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)

Related Tags for SCJP Module-3 Question-8:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.