Java Reference
In-Depth Information
Exercise 8.16
Go back to the
lab-classes
project from Chapter 1. Add instructors to the pro-
ject (every lab class can have many students and a single instructor). Use inheritance to avoid
code duplication between students and instructors (both have a name, contact details, etc.).
Exercise 8.17
Draw an inheritance hierarchy representing parts of a computer system
(processor, memory, disk drive, DVD drive, printer, scanner, keyboard, mouse, etc.).
Exercise 8.18
Look at the code below. You have four classes (
O
,
X
,
T
, and
M
) and a variable
of each of these.
O o;
X x;
T t;
M m;
The following assignments are all legal (assume that they all compile):
m = t;
m = x;
o = t;
The following assignments are all illegal (they cause compiler errors):
o = m;
o = x;
x = o;
What can you say about the relationships of these classes? Draw a class diagram.
Exercise 8.19
Draw an inheritance hierarchy of
AbstractList
and all its (direct and
indirect) subclasses as they are defined in the Java standard library.
Search WWH ::
Custom Search