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
(2)
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.