Ch 10 - Gaddis Flashcards
Inheritance
Inheritance allows a new class to extend an existing class. The new class inherits the members of the class it extends. The Java API has a class named Object, which all other classes directly or indirectly inherit from.
super
The super keyword refers to an object’s superclass. You can use the super key word to call a superclass constructor.
Overriding superclass methods
A subclass may have a method with the same signature as a superclass method. In such a case, the subclass method overrides the superclass method.
Protected members
Protected members of a class may be accessed by methods in a subclass, and by methods in the same package as the class.
Chains of inheritance
A superclass can also inherit from another class.
Polymorphism
A superclass reference variable can reference objects of a subclass.
Abstract classes & abstract methods
An abstract class is not instantiated, but other classes extend it. An abstract method has no body and must be overridden in a subclass.
Interface
An interface specifies behavior for a class.
Anonymous inner classes
An inner class is a class that is defined inside another class. An anonymous inner class is an inner class that has no name. An anonymous inner class must implement an interface, or extend another class.
Functional interfaces & lambda expressions
A functional interface is an interface that has one abstract method. You can use a special type of expression, known as a lambda expression, to create an object that implements a functional interface (Java 8).