Get ahead with a $300 test prep scholarship
| Enter to win by Tuesday 9/24
Quick Reference 17
Terms in this set (27)
A built-in Java interface that declares a compareTo method that accepts any Object as its argument. (See the Methods section below.) [This interface is known as "the raw Comparable interface". It remains — for the moment, at least — in the Java language so that code written for older versions of Java will continue to run.]
If T is a reference data type, a built-in Java interface that declares a compareTo method for instances of T. (See the Methods section below.)
A class that is declared using the abstract keyword. It cannot be instantiated.
A method that is declared using the abstract keyword and with a statement-ending semicolon taking the place of an empty body. (Any class that contains one or more abstract methods must itself be abstract.)
A class that is not an abstract class, that is, its declaration does not involve the abstract keyword. It can be instantiated. In order for a subclass of an abstract class to be concrete, it and its superclasses must, between them, implement all the abstract methods in all of its abstract superclasses.
Consistent with equals
The implementation of the compareTo method in a class that implements the Comparable<T> interface (where T is a reference data type) is said to be consistent with equals if the class overrides the equals method of Object in such a way that, whenever c is an instance of the class and t is an instance of T, c.compareTo( t ) evaluates to 0 if and only if c.equals( t ) evaluates to true.
A verbal description governing how any implementation of an abstract method is supposed to behave.
Implement an abstract method
To define a method in a subclass of an abstract class or in a class that implements an interface in which the abstract method is declared. The method must override the abstract method in the sense that it has the same return data type as the abstract method and its signature matches that of the abstract method. Furthermore, its definition must not involve the keyword abstract.
Implement an interface
A class implements an interface when its header includes the keyword implements followed by the name of the interface. In order for such a class to be concrete, its declaration must not involve the keyword abstract, it and its superclasses must, between them, implement all the abstract methods in all of its abstract superclasses, in the interface in question, and in all the superinterfaces of that interface.
A data type, declared using the keyword interface and having a body that does nothing but declare zero or more public, abstract methods and zero or more public, static, final constants. The keywords public and abstract should be omitted from any method declarations, any constants must be initialized, and any or all of the keywords public, static, and final may be omitted from any constant declarations.
An interface whose declaration has an empty body.
abstract (for classes)
The keyword that, when it appears in the header of a class definition or a method definition, designates the class as being an abstract class
abstract (for methods)
The keyword that, when it appears in the header of a class definition or a method definition, designates the method as being an abstract method.
The keyword that, when it appears in the header of a class definition, designates the class as an implementation of the interface(s) whose name(s) follow(s) the keyword. (If two or more interface names follow the keyword, they should be separated by commas.)
The keyword that designates a data type as being an interface.
In a class that implements the Comparable<T> interface (where T is a reference data type) — see the Data types section above — a method with signature compareTo( T t ), a return data type of int, and a general contract that requires the method to compare instances of T (or any of its subclasses) in accordance with the natural ordering on such instances.
In a class that implements the raw Comparable interface — see the Data types section above — a method with signature compareTo( Object o ), a return data type of int, and a general contract that requires the method to compare instances of the implementing class in accordance with the natural ordering on such instances.
A chart providing a side-by-side comparison between abstract classes and interfaces.
C is abstract; cannot be instantiated
When an attempt is made to instantiate an abstract class, C, program execution is interrupted and an error of this type is generated.
C is not abstract and does not override abstract method M in superC
When a class C is declared without using the keyword abstract and if the abstract method M from a class superC that it extends or an interface superC that it implements has not yet been overridden either in C or one of its superclasses, program execution is interrupted and an error of this type is generated.
has no constructor
either has one or more constructors that are explicitly defined, or it has a default, no-argument, empty-body constructor supplied by Java.
All the methods are automatically public and abstract.
may have only abstract methods, or a mixture of abstract and non-abstract methods, or only non-abstract methods.
Any variables that are declared here are automatically public, static, and final, and they must be initialized.
may contain variables of any kind: instance variables, class variables (those marked as static), and class constants (variables marked as static and final). None of them has to be initialized, and they may be public or private.
totally independent of class hierarchies;
can extend another abstract class or be extended by another (abstract or concrete) class, and in consequence belong to a hierarchy of classes.