Leave a Reply 3

Your email address will not be published. Required fields are marked *


renko

renko

Answer: C
package q075;

class Base {
public void test() {
System.out.println(“Base”);
}
}
package q075;

class DerivedA extends Base {
public void test() {
System.out.println(“DerivedA “);
}
}
package q075;

public class DerivedB extends DerivedA{
public void test() {
System.out.println(“DerivedB “);
}
public static void main(String[] args) {
Base b1 = new DerivedB();
Base b2 = new DerivedA();
Base b3 = new DerivedB();

b1 = (Base) b3;
Base b4 = (DerivedA) b3;
b1.test();
b4.test();

}

}
/* Output:
DerivedB
DerivedB
*/