Class and Interface Hierarchy

This section describes Java class and interface hierarchical relationships to support object inheritance: superclass-subclass relation, superinteface-subinterface relation, and interface-class relation.

Java allows classes and interfaces to be created with hierarchical relationship to support object inheritance. The class and interface hierarchy supports 3 types of relations:

1. Superclass-Subclass Relation - The subclass extends the superclass and inherits all behaviors of the superclass. An example is listed below:

class javax.net.ssl.X509ExtendedKeyManager 
   extends java.lang.Object {};
   // superclass: java.lang.Object
   // subclass: javax.net.ssl.X509ExtendedKeyManager

2. Superinteface-Subinterface Relation - The subinterface extends the superinterface and inherits all behaviors of the superinterface. An example is listed below:

interface javax.net.ssl.X509KeyManager 
   extends javax.net.ssl.KeyManager {};
   // superinterface: javax.net.ssl.KeyManager
   // subinterface: javax.net.ssl.X509KeyManager

3. Interface-Class Relation - The class implements the interface and inherits all behaviors of the interface. An example is listed below:

class javax.net.ssl.X509ExtendedKeyManager 
   implements javax.net.ssl.X509KeyManager {};
   // interface: javax.net.ssl.X509KeyManager
   // class: javax.net.ssl.X509ExtendedKeyManager

The diagram below shows you a simple class interface hierarchy example:
Java Class Interface Hierarchy Example

By default, all classes extend the java.lang.Object class. In other words, all classes are subclasses of the java.lang.Object class.

Last update: 2014.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows

 Execution Process, Entry Point, Input and Output

 Primitive Data Types and Literals

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

Reference Data Types and Variables

 Reference Types Supported in Java

 Creating Class Type Objects

 Class Type Variables Storing References

 Interface Type Variables

Class and Interface Hierarchy

 Supertype and Subtype

 Explicit and Implicit Type Casting

 Type Casting Example Program

 Type Casting Compile and Runtime Error

 StringBuffer - The String Buffer Class

 System Properties and Runtime Object Methods

 Generic Classes and Parameterized Types

 Generic Methods and Type Inference

 Lambda Expressions and Method References

 Execution Threads and Multi-Threading Java Programs

 ThreadGroup Class and "system" ThreadGroup Tree

 Synchronization Technique and Synchronized Code Blocks

 Deadlock Condition Example Programs

 Garbage Collection and the gc() Method

 Outdated Tutorials

 References

 PDF Printing Version