Java Reference
In-Depth Information
superclass method calls Calls to non-private instance methods from within a superclass are
always evaluated in the wider context of the object's dynamic type.
multiple inheritance A situation in which a class inherits from more than one superclass is
called multiple inheritance.
interface A Java interface is a specification of a type (in the form of a type name and a set of
methods) that does not define any implementation for the methods.
Exercise 10.67 Can an abstract class have concrete (non-abstract) methods? Can a
concrete class have abstract methods? Can you have an abstract class without abstract
methods? Justify your answers.
Exercise 10.68 Look at the code below. You have five types—classes or interfaces—(U, G,
B, Z, and X) and a variable of each of these types.
U u;
G g;
B b;
Z z;
X x;
The following assignments are all legal (assume that they all compile).
u = z;
x = b;
g = u;
x = u;
The following assignments are all illegal (they cause compiler errors).
u = b;
x = g;
b = u;
z = u;
g = x;
What can you say about the types and their relationships? (What relationship are they to each
Exercise 10.69 Assume that you want to model people in a university to implement a course
management system. There are different people involved: staff members, students, teaching
staff, support staff, tutors, technical-support staff, and student technicians. Tutors and student
technicians are interesting: tutors are students who have been hired to do some teaching, and
student technicians are students who have been hired to help with the technical support.
Draw a type hierarchy (classes and interfaces) to represent this situation. Indicate which types
are concrete classes, abstract classes, and interfaces.
Search WWH ::

Custom Search