Java Reference
In-Depth Information
K EY T ERMS
abstract class
560
marker interface
577
abstract method
560
shallow copy
579
deep copy
579
subinterface
582
interface
560
C HAPTER S UMMARY
1. Abstract classes are like regular classes with data and methods, but you cannot create
instances of abstract classes using the new operator.
2. An abstract method cannot be contained in a nonabstract class. If a subclass of an
abstract superclass does not implement all the inherited abstract methods of the
superclass, the subclass must be defined as abstract.
3. A class that contains abstract methods must be abstract. However, it is possible to
define an abstract class that doesn't contain any abstract methods.
4. A subclass can be abstract even if its superclass is concrete.
5. An interface is a class-like construct that contains only constants and abstract meth-
ods. In many ways, an interface is similar to an abstract class, but an abstract class can
contain constants and abstract methods as well as variables and concrete methods.
6. An interface is treated like a special class in Java. Each interface is compiled into a
separate bytecode file, just like a regular class.
7. The java.lang.Comparable interface defines the compareTo method. Many
classes in the Java library implement Comparable .
8. The java.lang.Cloneable interface is a marker interface . An object of the class
that implements the Cloneable interface is cloneable.
9. A class can extend only one superclass but can implement one or more interfaces.
10. An interface can extend one or more interfaces.
T EST Q UESTIONS
Do the test questions for this chapter online at www.cs.armstrong.edu/liang/intro9e/test.html .
P ROGRAMMING E XERCISES
Sections 15.2-15.3
**15.1
( Plot functions using abstract methods ) Write an abstract class that draws the
diagram for a function. The class is defined as follows:
public abstract class AbstractDrawFunction extends JPanel {
/** Polygon to hold the points */
private Polygon p = new Polygon();
 
 
Search WWH ::




Custom Search