Interfaces and Abstract Classes
in Detailed Design
|
Prof. David Bernstein
James Madison University
|
|
Computer Science Department
|
bernstdh@jmu.edu
|
Interfaces (cont.)
To Think About:
Interfaces in Java
- Syntax:
-
accessibility interface name { [variables]... [methods]... }
- File Name:
- The name of the file containing an interface must be
exactly the same as the name of the interface (with
.java
appended).
Interfaces in Java (cont.)
An Example
javaexamples/oopbasics/emergency2/Prioritized.java
Interfaces in Java (cont.)
An Example (cont.)
javaexamples/oopbasics/emergency2/EmergencyMessage.java
Interfaces in Java (cont.)
An Example (cont.)
javaexamples/oopbasics/emergency2/Alert.java
Interfaces in Java (cont.)
An Example (cont.)
javaexamples/oopbasics/emergency2/AccidentReport.java
Interfaces in Java (cont.)
An Example (cont.)
javaexamples/oopbasics/emergency2/Driver.java
Abstract Classes in Java
- Syntax:
-
accessibility abstract class name { [variables]... [methods]... }
- File Name:
- The name of the file containing an abstract class must be
exactly the same as the name of the abstract class (with
.java
appended).
- Abstract Methods:
- The methods that must be implemented by "concrete" derived
classes also use the
abstract
keyword (and
have an empty body).
Abstract Classes in Java (cont.)
An Example
javaexamples/abstracts/AbstractContent.java
There's Always More to Learn