CSC 251 Chapter 10 & 11 Review Questions
super("Suzuki");
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 ___.
modelHigh.getFloors();
A class named Building has a public, nonstatic method named getFloors(). If School is a child class of Building, and modelHigh is an object of type School, which of the following statements is valid?
try saving the two class names together
A reliable way to discover which of two classes is the base class and which is the subclass is to ___.
a. abstract methods b. nonabstract methods (Both a & b)
Abstract classes can contain ___.
cannot instantiate objects from them
Abstract classes differ from other classes in that you ___.
Dwelling myHome = new Dwellng();
An abstract class Dwelling has two subclasses, SingleFamily and MultiFamily. None of the constructors for these classes requires any arguments. Which of the following statements is legal?
When you create a superclass and one or more subclasses, each object of the subclass "is a" superclass object.
true
A base class can also be called a superclass.
true
A compiler can decide to inline a final method—that is, determine the code of the method call when the program is compiled.
true
must contain a constructor
If the only constructor in a superclass requires arguments, its subclass ___.
The keyword super always refers to the parent class of the class in which you use it.
true
a. public b. protected (Both a & b)
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.
inherit from one abstract superclass at most
In Java, a class can ___.
You must code statements for the setType() method within both the Permanent and Temporary classes
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, which of the following statements must be true?
Dynamic
An application's ability to select the correct subclass method to execute is known as ___ method binding.
anotherThing is the same type as thing
Assume the following statement appears in a working Java program and that the equals() method has been overridden correctly in thing's class: if(thing.equals(anotherThing)) x = 1; You know that ___.
final
You use a ___ method access specifier when you create methods for which you want to prevent overriding in extended classes.
one
Each Java subclass has the ability to inherit from ___ parent class(es).
many of the methods a subclass needs have already been used and tested
Employing inheritance reduces errors because ___.
If a superclass constructor requires arguments, any constructor of its subclasses must call the superclass constructor as the last statement.
False
In Java, the concept of keeping data private is known as polymorphism.
False
Parent classes are more specific than their child classes.
False
The Object class equals() method takes two arguments.
False
memory address
The Object class equals() method considers two object references to be equal if they have the same ___.
interface
The alternative to multiple inheritance in Java is known as a(n) ___.
cannot
When a parent class contains a static method, child classes ___ override it.
overrides
When a subclass method has the same name and argument types as a superclass method, the subclass method ___ the superclass method.
reference
When you create a ___ in Java, you create a variable name in which you can hold the memory address of an object.
implements
When you create a class that uses an interface, you include the keyword ___ and the interface's name in the class header.
parent class
When you instantiate an object that is a member of a subclass, the ___ constructor executes first.
abstract class
When you want to provide some data or methods that subclasses can inherit, but you want the subclasses to override some specific methods, you should write a(n) ___.
BodyOfWater/River
Which of the following choices is the best example of a parent class/child class relationship?
a. (Answer) superclasses can contain abstract methods b. an abstract class cannot have an abstract method c. superclass objects are members of their subclass d. you can create an abstract class object using the new operator
Which of the following statements is true?
a. a parent class inherits from a child class b. (Answer) a child class inherits from a parent class c. both of the preceding statements are true d. neither a nor b is true
Which of the following statements is true?
Currency[ ] currencyref = new Currency[5];
Which statement creates an array of five references to an abstract class named Currency ?
static
Within a subclass, you cannot override ___ methods.
can
You ___ override the toString() method in any class you create.
a. its class b. the class's superclass (Both a & b)
You call a static method using the name of ___, a dot, and the method name.
a. abstract class b. interface (Neither a nor b)
You can instantiate concrete objects from a(n) ___.
The Java keyword that creates inheritance is inherits.
false