Chapter 9 Flashcards
Employing inheritance reduces errors because
Baby of the methods a subclass needs have already been used and tested
A base class can also be called a
Superclass
What is an example of a parent class/child class relationship?
BodyOfWater/River
A class named Building has public, no static method named getFloors(). If School is a child class of Building, and modelHigh is an object of type School, is modelHigh.getFloors() valid?
Yes
When a subclass method has the same name and argument types as a super class method, the subclass method ______ the superclass method.
Overrides
When you instantiate an object that is a member of a subclass, the ______ constructor executes first.
Parent class
If you only constructor in a superclass requires arguments, its subclass
Must contain a constructor
A child class Motorcycle extends a parent class Vehicle. Each class constructor requires one String argument. The Motorcycle class constructor can call the Vehicle class constructor with the statement
Super(“Suzuki”);
If you create a data field or method that is ______, it can be used within its own class or in any classes extended from that class.
Public or protected
You use a _____ method access specifier when you create methods for which you want to prevent overriding in extended classes.
Final
When a parent class contains a static method, child classes ______ override it.
Cannot
Abstract classes differ from other classes in that you
Cannot instantiate objects from them.
An abstract class Dwelling has two subclasses, SingleFamily and MultiFamily. None of the constructors for these classes requires any arguments. Is SingleFamily myHome = new SingleFamily() valid?
Yes
An abstract class Employee has two subclasses, Permanent and Temporary. The Employee class contains an abstract method named setType(). Before you can instantiate Permanent and Temporary objects, what is true?
You must code statements for the setType() method within both the Permanent and Temporary classes.
Super class ________ contain abstract methods.
Can