-
Specify the set of values and the set of operations
provided by each of the following Java primitive data types:
- char,
- int,
- double, and
- String.
-
What are the features of Java that
facilitate the creation of user-defined data types.
-
Explain how each of the following
Java features supports polymorphism:
- interfaces,
- abstract classes, and
- inheritance.
-
Suppose we define two concrete classes, A and B,
both of which are derived from the AbstractObject class
declared in Program .
Furthermore, let a and b be instances of
classes A and B (respectively) declared as follows:
public class A extends AbstractObject { ... };
public class B extends AbstractObject { ... };
Comparable a = new A();
Comparable b = new B();
Give the sequence of methods called in order to evaluate
a comparison such as ``a.isLT(b)''.
Is the result of the comparison true or false?
Explain. -
Consider the Int wrapper class defined in Program .
Explain the operation of the following program fragment:
Comparable i = new Int (5);
Comparable j = new Int (7);
boolean result = i.isLT (j);
-
Let c be an instance of some concrete class
derived from the AbstractContainer class
given in Program .
Explain how the statement
System.out.println (c);
prints the contents of the container
on the standard output stream. -
Suppose we have a container c
(i.e., an instance of some concrete class
derived from the AbstractContainer class
defined in Program )
which among other things happens to contain itself.
What happens when we invoke the toString method on c?
-
Enumerations and visitors provide two ways to do the same thing--to visit one-by-one all the objects in a container.
Give an implementation for the accept method
of the AbstractContainer class that uses an enumeration.
-
Is it possible to implement an enumeration using a visitor?
Explain.
-
Suppose we have a container which we know contains only
instances of the Int class defined in Program .
Design a Visitor which computes the sum of all the integers
in the container.
-
Consider the following pair of Associations:
Comparable a = new Association (new Int (3), new Integer (4));
Comparable b = new Association (new Int (3));
Give the sequence of methods called in order to evaluate
a comparison such as ``a.isEQ(b)''.
Is the result of the comparison true or false?
Explain.