Question: Consider the following Java code: interface I { long f1(); long f2(); } abstract class C implements I { public long f1() { return 5;
Consider the following Java code:
interface I { long f1(); long f2(); }
abstract class C implements I { public long f1() { return 5; } } class C2 extends C {
public long f1() { return 99; }
public long f2() { return f1() + 33333333 *super.f1(); }
}
class C3 extends C2 { public long f1() { return 88888888; } }
//... in some other class, perhaps in a main() method ... final I x = new C3(); final I y = new C2();
a. What are the static (compile-time) and dynamic (runtime) types ofx?Static: Dynamic:
b. What are the static and dynamic types ofy?Static: Dynamic:
c. Why must class C be declaredabstract?
Step by Step Solution
There are 3 Steps involved in it
a The static compiletime type of x is I as it is declared as an interface t... View full answer
Get step-by-step solutions from verified subject matter experts
