Share on Google+Share on Google+

SCJP Module-3 Question-8

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() {

class InnerClass {
String s = "InnerClass";

InnerClass() {

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 :



Posted on: July 12, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.