Chapter 4
Application Program Interfaces

   4.1 The Purpose of Interfaces
   4.2 Interfaces in Class Definitions
   4.3 Inspecting Interfaces through Web Pages
   4.4 Introspecting Class Implemetations
   4.5 Interface Classes and Abstract Classes
   4.6 Assignment #4: Syntax of Interfaces

4.1 The Purpose of Interfaces

||----------|| (output) method
|--------------   interface        |
| || |-||| |||                  -----
| 1- -2 3- 4-| (input) method    |--|--
| 5-||6|7- 8---   interface       -----
| |-||-|+---||                  ||||
| -9 -0 -- ----user interface    |   |
--------------

4.2 Interfaces in Class Definitions

Strip:

class In { 
  int count = 0; 
  In(){...} 
  static int readInt(){...} 
  static char readCh(){...} 
} 
Class nameIn
Fieldsint count
ConstructorsIn()
Methodsstatic int readInt()
static char readCh()

4.3 Inspecting Interfaces through Web Pages

4.4 Introspecting Class Implemetations

4.5 Interface Classes and Abstract Classes

4.6 Assignment #4: Syntax of Interfaces

Due: We, Apr 9, at class

Issue the command ‘javap -private java.lang.String’ and inspect its outcome. Provide the following information.

  1. Identify two instance fields of class ‘String’.
  2. Identify two class (static) fields of class ‘String’.
  3. Identify two constructors of class ‘String’.
  4. Identify two class (static) methods of class ‘String’.
  5. Identify two instance methods of class ‘String’.
  6. Identify all the modifiers in use within the interfaces.
  7. Identify all the listed primitive types.
  8. Identify all the listed class types.
Please submit your answers on paper.

Q&A