Consider the following Java code: interface I { long f1(); long f2(); } abstract class C implements
Fantastic news! We've Found the answer you've been seeking!
Question:
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?
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date: