class
Test {
int i = getX ( ) ;
int j = 10 ;
int getX ( ) {
return j ; //1
}
public static void main (
String args [ ] ) {
System . out . println ( new Test ( ) . i ) ;
}
};
Options :
a . Compiler error - can't call getX ( ) before the constructor completes initialization
b . Compiler error - variable j may not have been initialized
c . Compiles fine & prints 10
d . Compiles fine & prints 0
output d . Compiles fine & prints 0
I think there is a forward reference at //1 as j. But apprently i am worng ... so please someone tell me the real program flow !
Thanks