Deck 9: Inheritance

Full screen (f)
exit full mode
Question
Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree.

A) UML diagram
B) CRC card
C) flowchart
D) class hierarchy
Use Space or
up arrow
down arrow
to flip the card.
Question
When a class contains an abstract method, you cannot create an instance of the class.
Question
You can write a super statement that calls a superclass constructor but only in the subclass's constructor.
Question
In an inheritance relationship, the subclass constructor always executes before the superclass constructor.
Question
A __________ member's access is somewhere between public and private.

A) package
B) protected
C) static
D) final
Question
Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members.
Question
An abstract class is not instantiated itself but serves as a superclass for other classes.
Question
When an "is a" relationship exists between objects, it means that the specialized object has all the characteristics of the general object plus additional characteristics that make it special.
Question
A(n) __________ method is a method that appears in a superclass but expects to be overridden in a subclass.

A) abstract
B) protected
C) static
D) overloaded
Question
If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method.
Question
Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.
Question
You show inheritance in a UML diagram by connecting two classes with a line that has an open arrowhead pointing to the subclass.
Question
All fields declared in an interface

A) have protected access
B) must be initialized in the class implementing the interface
C) have private access
D) are treated as final and static
Question
What type of relationship exists between two objects when one object is a specialized version of another object?

A) "is a"
B) "contains a"
C) "has a"
D) "consists of"
Question
In object-oriented programming, __________ allows you to extend the capabilities of a class by creating another class that is a specialized version of it.

A) prototyping
B) code reusability
C) inheritance
D) data hiding
Question
When a subclass overrides a superclass method, only the subclass's version of the method can be called with a subclass object.
Question
When an "is a" relationship exists between objects, the specialized object has

A) some of the characteristics of the general class, but not all, plus additional characteristics
B) some, but not all, of the characteristics of the general object
C) none of the characteristics of the general object
D) all of the characteristics of the general object plus additional characteristics
Question
If a subclass constructor does not explicitly call a superclass constructor,

A) the superclass's fields will be set to the default values for their data types
B) Java will automatically call the superclass's default constructor immediately after the code in the subclass's constructor executes
C) it must include the code necessary to initialize the superclass fields
D) Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes
Question
In Java, a reference variable is __________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.

A) static
B) dynamic
C) polymorphic
D) public
Question
A subclass can directly access

A) only protected and private members of the superclass
B) all members of the superclass
C) only public and private members of the superclass
D) only public and protected members of the superclass
Question
All methods specified by an interface are

A) private
B) public
C) protected
D) static
Question
In a UML diagram you show a realization relationship by connecting a class and an interface with a

A) dashed line with an open arrowhead at one end
B) line with an open diamond at one end
C) dashed line
D) line with an open arrowhead at one end
Question
A class becomes abstract when you place the __________ key word in the class definition.

A) super
B) extends
C) final
D) abstract
Question
When a class does not use the extends key word to inherit from another class, Java automatically extends it from the __________ class.

A) Object
B) subclass
C) superclass
D) public
Question
If ClassC is derived from ClassB which is derived from ClassA, this would be an example of

A) a chain of inheritance
B) linear inheritance
C) multiple interfaces
D) cascading classes
Question
Which of the following is the operator used to determine whether an object is an instance of a particular class?

A) equals
B) instanceOf
C) >>
D) isa
Question
In the following statement, which is the superclass? public class ClassA extends ClassB implements ClassC

A) ClassA
B) ClassB
C) ClassC
D) both ClassB and ClassC are superclasses
Question
Protected class members can be denoted in a UML diagram with the __________ symbol.

A) +
B) -
C) *
D) #
Question
A protected member of a class may be directly accessed by

A) methods of the same class
B) methods of a subclass
C) methods in the same package
D) Any of these
Question
Which key word indicates that a class inherits from another class?

A) final
B) super
C) implements
D) extends
Question
In a class hierarchy

A) the more general classes are toward the right of the tree and the more specialized classes are toward the left
B) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom
C) the more general classes are toward the left of the tree and the more specialized classes are toward the right
D) the more general classes are toward the bottom of the tree and the more specialized classes are toward the top
Question
Which of the following statements declares Salaried as a subclass of PayType?

A) public class Salaried implements PayType
B) public class PayType derives Salaried
C) public class Salaried extends PayType
D) public class Salaried derivedFrom(PayType)
Question
When a class implements an interface, an inheritance relationship known as __________ inheritance is established.

A) implemented
B) interface
C) realized
D) abstract
Question
If a method in a subclass has the same signature as a method in the superclass, the subclass method __________ the superclass method.

A) inherits
B) overloads
C) overrides
D) implements
Question
In the following statement, which is the subclass?
public class ClassA extends ClassB implements ClassC

A) ClassA
B) ClassB
C) ClassC
D) both ClassB and ClassC are subclasses
Question
If you don't provide an access specifier for a class member, the class member is given __________ access by default.

A) private
B) public
C) protected
D) package
Question
In __________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass.

A) pseudocode
B) a UML diagram
C) a CRC card
D) a hierarchy chart
Question
In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC

A) ClassA
B) ClassB
C) ClassC
D) all are interfaces
Question
Which of the following statements correctly specifies two interfaces?

A) public class ClassA implements [Interface1, Interface2]
B) public class ClassA implements (Interface1, Interface2)
C) public class ClassA implements Interface1, Interface2
D) public class ClassA implements Interface1 | Interface2
Question
When a method is declared with the __________ modifier, it cannot be overridden in a subclass.

A) final
B) super
C) void
D) public
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Inheritance
1
Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree.

A) UML diagram
B) CRC card
C) flowchart
D) class hierarchy
D
2
When a class contains an abstract method, you cannot create an instance of the class.
True
3
You can write a super statement that calls a superclass constructor but only in the subclass's constructor.
True
4
In an inheritance relationship, the subclass constructor always executes before the superclass constructor.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
A __________ member's access is somewhere between public and private.

A) package
B) protected
C) static
D) final
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
An abstract class is not instantiated itself but serves as a superclass for other classes.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
When an "is a" relationship exists between objects, it means that the specialized object has all the characteristics of the general object plus additional characteristics that make it special.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
A(n) __________ method is a method that appears in a superclass but expects to be overridden in a subclass.

A) abstract
B) protected
C) static
D) overloaded
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
You show inheritance in a UML diagram by connecting two classes with a line that has an open arrowhead pointing to the subclass.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
All fields declared in an interface

A) have protected access
B) must be initialized in the class implementing the interface
C) have private access
D) are treated as final and static
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
What type of relationship exists between two objects when one object is a specialized version of another object?

A) "is a"
B) "contains a"
C) "has a"
D) "consists of"
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
In object-oriented programming, __________ allows you to extend the capabilities of a class by creating another class that is a specialized version of it.

A) prototyping
B) code reusability
C) inheritance
D) data hiding
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
When a subclass overrides a superclass method, only the subclass's version of the method can be called with a subclass object.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
When an "is a" relationship exists between objects, the specialized object has

A) some of the characteristics of the general class, but not all, plus additional characteristics
B) some, but not all, of the characteristics of the general object
C) none of the characteristics of the general object
D) all of the characteristics of the general object plus additional characteristics
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
If a subclass constructor does not explicitly call a superclass constructor,

A) the superclass's fields will be set to the default values for their data types
B) Java will automatically call the superclass's default constructor immediately after the code in the subclass's constructor executes
C) it must include the code necessary to initialize the superclass fields
D) Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
In Java, a reference variable is __________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.

A) static
B) dynamic
C) polymorphic
D) public
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
A subclass can directly access

A) only protected and private members of the superclass
B) all members of the superclass
C) only public and private members of the superclass
D) only public and protected members of the superclass
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
All methods specified by an interface are

A) private
B) public
C) protected
D) static
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
In a UML diagram you show a realization relationship by connecting a class and an interface with a

A) dashed line with an open arrowhead at one end
B) line with an open diamond at one end
C) dashed line
D) line with an open arrowhead at one end
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
A class becomes abstract when you place the __________ key word in the class definition.

A) super
B) extends
C) final
D) abstract
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
When a class does not use the extends key word to inherit from another class, Java automatically extends it from the __________ class.

A) Object
B) subclass
C) superclass
D) public
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
If ClassC is derived from ClassB which is derived from ClassA, this would be an example of

A) a chain of inheritance
B) linear inheritance
C) multiple interfaces
D) cascading classes
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following is the operator used to determine whether an object is an instance of a particular class?

A) equals
B) instanceOf
C) >>
D) isa
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
In the following statement, which is the superclass? public class ClassA extends ClassB implements ClassC

A) ClassA
B) ClassB
C) ClassC
D) both ClassB and ClassC are superclasses
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
Protected class members can be denoted in a UML diagram with the __________ symbol.

A) +
B) -
C) *
D) #
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
A protected member of a class may be directly accessed by

A) methods of the same class
B) methods of a subclass
C) methods in the same package
D) Any of these
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
Which key word indicates that a class inherits from another class?

A) final
B) super
C) implements
D) extends
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
In a class hierarchy

A) the more general classes are toward the right of the tree and the more specialized classes are toward the left
B) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom
C) the more general classes are toward the left of the tree and the more specialized classes are toward the right
D) the more general classes are toward the bottom of the tree and the more specialized classes are toward the top
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following statements declares Salaried as a subclass of PayType?

A) public class Salaried implements PayType
B) public class PayType derives Salaried
C) public class Salaried extends PayType
D) public class Salaried derivedFrom(PayType)
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
When a class implements an interface, an inheritance relationship known as __________ inheritance is established.

A) implemented
B) interface
C) realized
D) abstract
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
If a method in a subclass has the same signature as a method in the superclass, the subclass method __________ the superclass method.

A) inherits
B) overloads
C) overrides
D) implements
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
In the following statement, which is the subclass?
public class ClassA extends ClassB implements ClassC

A) ClassA
B) ClassB
C) ClassC
D) both ClassB and ClassC are subclasses
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
If you don't provide an access specifier for a class member, the class member is given __________ access by default.

A) private
B) public
C) protected
D) package
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
In __________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass.

A) pseudocode
B) a UML diagram
C) a CRC card
D) a hierarchy chart
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC

A) ClassA
B) ClassB
C) ClassC
D) all are interfaces
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following statements correctly specifies two interfaces?

A) public class ClassA implements [Interface1, Interface2]
B) public class ClassA implements (Interface1, Interface2)
C) public class ClassA implements Interface1, Interface2
D) public class ClassA implements Interface1 | Interface2
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
When a method is declared with the __________ modifier, it cannot be overridden in a subclass.

A) final
B) super
C) void
D) public
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.