Hi
I executed this code
class Just {
int a = 10 ;
Just ( ) {
call ( ) ;
}
void call ( ) {
System . out . print( "a = " + a + " ") ;
}
}
class Q05 extends Just {
int b = 16 ;
Q05 ( ) {
call ( ) ;
}
void call ( ) {
System.out.print( " b = " + b + " " ) ;
}
public static void main (
String args [ ] ) {
new Q05 ( ) ;
}
}
I got b=0 b=16 but i was expecting a=10 b=16 because main method is creating object of subclass so first super class constructor will get called and in turn super class constructor is calling call() method. so it should call
call() of
just class.why it is calling
call() of subclass method,
Please clarify my doubt.
Source:Voodoo mock exam Test3