Deck 8: Polymorphism and Abstract Classes
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/43
Play
Full screen (f)
Deck 8: Polymorphism and Abstract Classes
1
Early binding enables the compiler to be more efficient.
True
2
You cannot create an object using a/an:
A)superclass constructor
B)subclass constructor
C)ancestor class constructor
D)abstract class constructor
A)superclass constructor
B)subclass constructor
C)ancestor class constructor
D)abstract class constructor
D
3
The clone method return type is:
A)the same as the cloned object
B)Object
C)String
D)none of the above
A)the same as the cloned object
B)Object
C)String
D)none of the above
B
4
____________ refers to the process of associating a method definition with a method invocation.
A)Binding
B)Encapsulation
C)Inheritance
D)Polymorphism
A)Binding
B)Encapsulation
C)Inheritance
D)Polymorphism
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
5
A class that has at least one abstract method is called an:
A)concrete class
B)encapsulated class
C)abstract class
D)private class
A)concrete class
B)encapsulated class
C)abstract class
D)private class
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
6
Polymorphism refers to the ability to associate many meanings to one method through dynamic binding.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
7
Java does not use late binding for methods marked as:
A)final
B)static
C)private
D)all of the above
A)final
B)static
C)private
D)all of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
8
If you choose to use the method clone in your code,you must ___________ the clone method.
A)overload
B)encapsulate
C)override
D)protect
A)overload
B)encapsulate
C)override
D)protect
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
9
__________ refers to the ability to associate many meanings to one method name by means of the late binding mechanism.
A)Inheritance
B)Encapsulation
C)Polymorphism
D)None of the above
A)Inheritance
B)Encapsulation
C)Polymorphism
D)None of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
10
Assigning an object of a derived class to a variable of a base class is called:
A)static binding
B)dynamic binding
C)upcasting
D)downcasting
A)static binding
B)dynamic binding
C)upcasting
D)downcasting
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
11
__________ binding refers to the method definition being associated with the method invocation when the code is compiled.
A)Dynamic
B)Late
C)Early
D)None of the above
A)Dynamic
B)Late
C)Early
D)None of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
12
An abstract class must have the modifier ___________ included in the class heading.
A)static
B)abstract
C)final
D)private
A)static
B)abstract
C)final
D)private
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
13
The principals of object oriented programming include:
A)encapsulation
B)inheritance
C)polymorphism
D)all of the above
A)encapsulation
B)inheritance
C)polymorphism
D)all of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
14
Late binding refers to the method definition being associated with the method invocation when the method is invoked at run time.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
15
The clone method has ________ parameters.
A)zero
B)one
C)two
D)three
A)zero
B)one
C)two
D)three
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
16
An abstract method cannot be modified by:
A)public
B)protected
C)private
D)none of the above
A)public
B)protected
C)private
D)none of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
17
A class with no abstract methods is called a
A)concrete class
B)encapsulated class
C)abstract class
D)private class
A)concrete class
B)encapsulated class
C)abstract class
D)private class
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
18
Assigning an object of an ancestor class to a descendent class is called:
A)static binding
B)dynamic binding
C)upcasting
D)downcasting
A)static binding
B)dynamic binding
C)upcasting
D)downcasting
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
19
A method marked as final means the compiler uses ________ binding.
A)dynamic
B)early
C)late
D)none of the above
A)dynamic
B)early
C)late
D)none of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
20
Java allows an instance of an abstract class to be instantiated.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
21
An abstract method serves as a placeholder for a method that must be defined in all derived classes.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
22
Draw an inheritance hierarchy to represent a shoe object.The base class should have derived classes of Dress Shoes,Tennis Shoes and Boots.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
23
Describe the limitations of the copy constructor.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
24
Downcasting should be used only in situations where it makes sense.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
25
What is wrong with the following method definition?
public abstract void doSomethingint count)
public abstract void doSomethingint count)
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
26
The method clone has one parameter and should return a copy of the calling object.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
27
The type of the variable naming an object determines which method names can be used in an invocation with that calling object.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
28
Why should the instanceOf operator be used in conjunction with downcasting?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
29
What is polymorphism and how does it relate to late binding?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
30
The final modifier is included before the definition of the method,then the method can be redefined in a derived class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
31
Explain the difference between early and late binding.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
32
Derive a class named Dress Shoes from the base class created in number 9 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
33
An abstract class is a class that has some methods without complete definitions.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
34
Java uses late binding with private methods,methods marked final,or static methods.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
35
What are the advantages of polymorphism?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
36
Derive a class named Boots from the base class created in number 9 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
37
Implement the base class in the shoe hierarchy in number 8 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
38
Write a decision statement to determine if an object should be downcast.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
39
Derive a class named Tennis Shoes from the base class created in number 9 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
40
What is an abstract method?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
41
Override the clone method inherited in the Boots class created in number 12 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
42
Override the clone method inherited in the Tennis Shoes class created in number 11 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
43
Override the clone method inherited in the Dress Shoes class created in number 10 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck