The Department of Computer Science & Engineering

CSE 115
Introduction To Computer Science for Majors I
Lecture C
Lecture Notes
Stuart C. Shapiro
Spring, 2001


Brown U. Notes, Chapter 4
Barnes, Chapter 14 (Reference only---much advanced material)

A class extends its superclass.

Inheritance: a (child) subclass inherits attributes and behaviors from its (parent) superclass, its superclass, etc., and it specializes them.
The superclass generalizes its subclasses.

A class may extend only one superclass. (No multiple inheritance.)

is-a: A dog is-a mammal, a mammal is-a vertebrate.

A superclass is abstract if it has at least one abstract method.
An abstract method has no body (not even an empty body).
abstract public void move();
This requires every subclass to have this method.
A class with no abstract methods is concrete.
Only concrete classes may have instances.

super(args);: Call to the parent class's constructor.
Must be the first statement of the child's constructor.
If missing, Java compiler will insert super();

May have multiple methods (esp. constructors) with same name, but different signatures. Compiler will arrange for a call to the matching one.

this: The current instance.

Additional access modifier:
private: accessible only to class within which it's declared.
protected: accessible to class within which it's declared, and all subclasses (and every class in package).
public: accessible to every class.

See Inheritance demonstration and its documentation.

First Previous Next

Copyright © 2001 by Stuart C. Shapiro. All rights reserved.

Stuart C. Shapiro <>