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
Step: 1
a The static compiletime type of x is I as it is declared as an interface t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Building Java Programs A Back To Basics Approach
Authors: Stuart Reges, Marty Stepp
5th Edition
013547194X, 978-0135471944
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App