class OuterTest {
String id ;
OuterTest ( ) {
this.id = " Default " ;
}
OuterTest ( String id ) {
this.id = id ;
}
class InnerTest extends OuterTest {
void doSomething ( ) {
System . out . println ( OuterTest.this.id ) ;
}
};
public static void main ( String args [ ] ) {
OuterTest outer = new OuterTest ( " STP " ) ;
InnerTest inner = outer . new InnerTest ( ) ;
inner.doSomething ( ) ;
}
};
Hi,
The above code prints output as " STP ". When the inner class instance is created using outer class, the inner class constructor calls super class constructor which basically executes this.id = "default". I thought it should print "default" instead of " STP ". Please clarify.