CISC 190 chapter 10: Inheritance concepts and vocab

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

10.1 what is inheritance?

inheritance allows a new class to extend an existing class. the new class inherits the members of the class it extends.

10.4 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.

10.6 the object class

the Java API has a class named Object, which all other classes directly or indirectly inherit from.

10.2 calling the superclass constructor

the super key word refers to an object's superclass. you can use the super key word to call a superclass constructor.

10.11 functional interfaces and 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.

10.3 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.

10.5 chains of inheritance

a superclass can also inherit from another class.

10.7 polymorphism

a superclass reference variable can reference objects of a subclass.

10.8 abstract classes and 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.

10.10 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.

10.9 interfaces

an interface specifies behavior for a class.

10.12 common errors to avoid

attempting to access a private superclass member directly from a subclass. forgetting to call a superclass constructor explicitly when the superclass does not have a default constructor or a programmer-defined no-arg constructor. allowing the superclass's no-arg constructor to be implicitly called when you intend to call another superclass constructor. forgetting to precede a call to an overridden superclass method with super. forgetting a class member's access specifier. writing a body for an abstract method. forgetting to terminate an abstract method's header with a semicolon. failing to override an abstract method. overloading an abstract method instead of overriding it. trying to instantiate an abstract class. implementing an interface but forgetting to provide all of the methods specified by the interface. writing a method specified by an interface but failing to use the exact signature and return type.


Kaugnay na mga set ng pag-aaral

Chapter 14 Forging the National Economy

View Set

Chapter 9: Multivariate Correlatioional Research

View Set

1. 2. 3. ¿Cuántos hay? How many are there? Y números treinta al sesenta

View Set

Lab 3: Vital Signs, and Nursing Assessment.

View Set

Algebra 2 "Alg. 2 Diagnostic Review Worksheet"

View Set