Question: interface I { int f(); int g();} abstract class C implements I {public int f() {return 3;} } class D extends C { public int

interface I { int f(); int g();}

abstract class C implements I {public int f() {return 3;} }

class D extends C {

public int f() { return 7; }

public int g() { return f() + 5 * super.f(); }

}

class E extends D { public int f() {return 11;} }

class F extends E { public int f() {return f();} }

//... in some other class, perhaps in main()...

final I x = new D(); System.out.println(x.g());

final I y = new E(); System.out.println(y.g());

// a What does the code print? (the two system.out.println()'s)

// b What are the static (compile time) and dynamic (runtime) types of x? Static: Dynamic:

// c What are hte static and dynamic types of y? Static: Dynamic:

// d In the context of the code above, what happens when you evaluate the expression new F().f() (this is legitimate "method chaining")? If there is any problem, what causes it?

// e Why must class C be declared as abstract? (implements one interface, does not implement all the methods in interface, does not have any instance variables, does not have a superclass)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!