TOPUPchat logo...
Forgot password?

Select : C language | Java

Q.3] using different datatype for abject reference

class Fuit{
    final int a=5;
}

class Mango extends Fruit{
    final int a=10;
}

class DynamicDispatch  extends Mango{
    final int a=15;
  
    public static void main(String[] args){
        DynamicDispatch t=new Fruit();
        System.out.print(t.a);
    }
}

    

Options]

A)15
B)runtime error
C)compile time error
D)1 warning        

Click to See Answer
C)compile time error    

Next |

Previous | IDE shows error on line no. 4 select replacement for it from options

Hemen Ashodia [paper setter]
Register & recharge
Male Female
I agree Terms and Conditions