CISP 1020 Ch. 9
What type of relationship exists between two objects when one object is a specialized version of another object?
"is a"
Which of the following is true about protected access?
Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package.
A subclass can directly access ________.
only public and protected members of the superclass
A(n) ________ method is a method that appears in a superclass but expects to be overridden in a subclass.
abstract
A subclass may call an overridden superclass method by ________.
prefixing its name with the super key word and a dot (.)
The ________ key word is used to call a superclass constructor explicitly.
super
In a class hierarchy ________.
the more general classes are toward the top of the tree and the more specialized classes are toward the bottom
When a method is declared with the ________ modifier, it cannot be overridden in a subclass.
final
A protected member of a class may be directly accessed by ________.
methods of a subclass, methods in the same package, methods of the same class
When declaring class data members it is best to declare them as ________.
private members
Given the following code: Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1(int a){} Line 5 } Line 6 public class ClassB extends ClassA Line 7 { Line 8 public ClassB(){} Line 9 public void method1(){} Line 10 } Line 11 public class ClassC extends ClassB Line 12 { Line 13 public ClassC(){} Line 14 public void method1(){} Line 15 }
This is an error and will cause the program to crash.
A class becomes abstract when you place the ________ key word in the class definition.
abstract
When an "is a" relationship exists between objects, the specialized object has ________.
all of the public and protected variables and methods of the general object plus additional characteristics
When a subclass overloads a superclass method ________.
both methods may be called with a subclass object
Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree?
class hierarchy
If two methods have the same name but different signatures they are ________.
overloaded
Which of the following is the operator used to determine whether an object is an instance of a particular class?
instanceOf
In an inheritance relationship ________.
the superclass constructor always executes before the subclass constructor
If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method.
overrides