class
Test {
int i = getX ( ) ;
int j = 10 ;
int getX ( ) {
return j ;
}
public static void main (
String args [ ] ) {
System . out . println ( new Test ( ) . i + " " + new Test() . getX() );
}
};
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 10
d . Compiles fine & prints 0 10
The correct answer is d
Can anyone explain me.
[ February 28, 2007: Message edited by: Pankaja Shinde ]