CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Inheritance

Inheritance
Introduction
How inheritance works

Inheritance is a mechanism that enables one class to inherit behavior and attributes of another class

Inheritance concepts

  • Inheritance lets you create a new class based on an existing class. The new class inherits the fields, constructors, and methods of the existing class.
  • A class that inherits from an existing class is called a derived class, child class, or subclass.
  • A class that another class inherits is called a base class, parent class, or superclass.
  • A subclass can extend the superclass by adding new fields, constructors, and methods to the superclass.
  • A subclass can override a method from the superclass with its own version of the method.

Previous | How inheritance works | Java API | Object class | Use | Next