{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

shw8 - 4 D inherits from C 5 D inherits from B 6 E inherits...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Suggested Homework #8 (for Quiz #8 on 12/14/07 with Final) Consider the Java code below: interface A { void m(A y); } interface C extends A { A n(C y); } class B implements A { int x; void m(A y){ return; } } class D extends B { int y; } class E extends B implements C { A n(C z){ return z; } } (a) Name the types, classes, and interfaces that have been created. (b) Using the notion of structural subtyping which of the following is true ? (i) A <: B (ii) A <: C (iii) B <: A (iv) D <: C (v) D <: B (vi) E <: C (vii) E <: B (viii) E <: A (c) Which of the following is true ? 1. A inherits from B 2. A inherits from C 3. B inherits from A
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 4. D inherits from C 5. D inherits from B 6. E inherits from C 7. E inherits from B 8. E inherits from A (d) Which of the following methods typecheck ? (i) void fa(A x){ x.m(x); }; (ii) void fb(B x){ x.n(x); }; (iii) void fc(C x){ x.n(x); }; (e) Suppose that there were methods fa,fb,fc with the signatures shown in part (d). Which of the following pieces of code typecheck ? Explain. (i) A a = A(); fa(a); (ii) B b = B(); fa(b); (iii) B b = B(); fc(b); (iv) D d = D(); fa(d); (v) D d = D(); fa(d); fb(d); fc(d); (vi) E e = E(); fa(e); fb(e); fc(e);...
View Full Document

{[ snackBarMessage ]}