Deck 10: Object-Oriented Programming: Polymorphism

Full screen (f)
exit full mode
Question
Which statement best describes the relationship between superclass and subclass types?

A)A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable.
B)A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable.
C)A superclass reference can be assigned to a subclass variable,but a subclass reference cannot be assigned to a superclass variable.
D)A subclass reference can be assigned to a superclass variable,but a superclass reference cannot be assigned to a subclass variable.
Use Space or
up arrow
down arrow
to flip the card.
Question
Polymorphism enables you to:

A)program in the general.
B)program in the specific.
C)absorb attributes and behavior from previous classes.
D)hide information from the user.
Question
Consider classes A,B and C,where A is an abstract superclass,B is a concrete class that inherits from A and C is a concrete class that inherits from B.Class A declares abstract method originalMethod,implemented in class B.Which of the following statements is true of class C?

A)Method originalMethod cannot be overridden in class C-once it has been implemented in concrete class B,it is implicitly final.
B)Method originalMethod must be overridden in class C,or a syntax error will occur.
C)If method originalMethod is not overridden in class C but is called by an object of class C,an error occurs.
D)None of the above.
Question
Classes and methods are declared final for all but the following reasons:

A)final methods allow inlining the code.
B)final methods and classes prevent further inheritance.
C)final methods are static.
D)final methods can improve performance.
Question
When a superclass variable refers to a subclass object and a method is called on that object,the proper implementation is determined at execution time.What is the process of determining the correct method to call?

A)early binding.
B)non-binding.
C)on-time binding.
D)late binding.
Question
An interface may contain:

A)private static data and public abstract methods.
B)only public abstract methods.
C)public static final data and public abstract methods.
D)private static data and public final methods.
Question
Which of the following statements about abstract superclasses is true?

A)abstract superclasses may contain data.
B)abstract superclasses may not contain implementations of methods.
C)abstract superclasses must declare all methods as abstract.
D)abstract superclasses must declare all data members not given values as abstract.
Question
class cannot be instantiated.

A)final.
B)concrete.
C)abstract.
D)polymorphic.
Question
Polymorphism allows for specifics to be dealt with during:

A)execution.
B)compilation.
C)programming.
D)debugging.
Question
For which of the following would polymorphism not provide a clean solution?

A)A billing program where there is a variety of client types that are billed with different fee structures.
B)A maintenance log program where data for a variety of types of machines is collected and maintenance schedules are produced for each machine based on the data collected.
C)A program to compute a 5% savings account interest for a variety of clients.
D)An IRS program that maintains information on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.
Question
All of the following methods are implicitly final except:

A)a method in an abstract class.
B)a private method.
C)a method declared in a final class.
D)static method.
Question
Assigning a subclass reference to a superclass variable is safe:

A)because the subclass object has an object of its superclass.
B)because the subclass object is an object of its superclass.
C)only when the superclass is abstract.
D)only when the superclass is concrete.
Question
Non-abstract classes are called:

A)real classes.
B)instance classes.
C)implementable classes.
D)concrete classes.
Question
Every object in Java knows its own class and can access this information through method .

A)getClass.
B)getInformation.
C)objectClass.
D)objectInformation.
Question
If the superclass contains only abstract method declarations,the superclass is used for:

A)implementation inheritance.
B)interface inheritance.
C)Both.
D)Neither.
Question
Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)?

A)public int method1();
B)public int abstract method1();
C)public abstract int method1();
D)public int nonfinal method1();
Question
It is a UML convention to denote the name of an abstract class in:

A)bold.
B)italics.
C)a diamond.
D)there is no convention of the UML to denote abstract classes-they are listed just as any other class.
Question
Which of the following does not complete the sentence correctly? An interface .

A)forces classes that implement it to declare all the interface methods.
B)can be used in place of an abstract class when there is no default implementation to inherit.
C)is declared in a file by itself and is saved in a file with the same name as the interface followed by the .java extension.
D)can be instantiated.
Question
Which of the following statements about interfaces is false?

A)An interface describes a set of methods that can be called on an object,providing a default implementation for the methods.
B)An interface describes a set of methods that can be called on an object,not providing concrete implementation for the methods.
C)Interfaces are useful when attempting to assign common functionality to possibly unrelated classes.
D)Once a class implements an interface,all objects of that class have an is-a relationship with the interface type.
Question
Declaring a method final means:

A)it will prepare the object for garbage collection.
B)it cannot be accessed from outside its class.
C)it cannot be overloaded.
D)it cannot be overridden.
Question
A class that implements an interface but does not declare all of the interface's methods must be declared:

A)public.
B)interface.
C)abstract.
D)final.
Question
Which of the following is not possible?

A)A class that implements two interfaces.
B)A class that inherits from two classes.
C)A class that inherits from one class,and implements an interface.
D)All of the above are possible.
Question
The UML distinguishes an interface from other classes by placing the word "interface" in above the interface name.

A)italics.
B)carets.
C)guillemets.
D)bold.
Question
Interfaces can have methods.

A)0
B)1
C)2
D)any number of
Question
Which keyword is used to specify that a class will define the methods of an interface?

A)uses.
B)implements.
C)defines.
D)extends.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Object-Oriented Programming: Polymorphism
1
Which statement best describes the relationship between superclass and subclass types?

A)A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable.
B)A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable.
C)A superclass reference can be assigned to a subclass variable,but a subclass reference cannot be assigned to a superclass variable.
D)A subclass reference can be assigned to a superclass variable,but a superclass reference cannot be assigned to a subclass variable.
D
2
Polymorphism enables you to:

A)program in the general.
B)program in the specific.
C)absorb attributes and behavior from previous classes.
D)hide information from the user.
A
3
Consider classes A,B and C,where A is an abstract superclass,B is a concrete class that inherits from A and C is a concrete class that inherits from B.Class A declares abstract method originalMethod,implemented in class B.Which of the following statements is true of class C?

A)Method originalMethod cannot be overridden in class C-once it has been implemented in concrete class B,it is implicitly final.
B)Method originalMethod must be overridden in class C,or a syntax error will occur.
C)If method originalMethod is not overridden in class C but is called by an object of class C,an error occurs.
D)None of the above.
D
4
Classes and methods are declared final for all but the following reasons:

A)final methods allow inlining the code.
B)final methods and classes prevent further inheritance.
C)final methods are static.
D)final methods can improve performance.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
When a superclass variable refers to a subclass object and a method is called on that object,the proper implementation is determined at execution time.What is the process of determining the correct method to call?

A)early binding.
B)non-binding.
C)on-time binding.
D)late binding.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
An interface may contain:

A)private static data and public abstract methods.
B)only public abstract methods.
C)public static final data and public abstract methods.
D)private static data and public final methods.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following statements about abstract superclasses is true?

A)abstract superclasses may contain data.
B)abstract superclasses may not contain implementations of methods.
C)abstract superclasses must declare all methods as abstract.
D)abstract superclasses must declare all data members not given values as abstract.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
class cannot be instantiated.

A)final.
B)concrete.
C)abstract.
D)polymorphic.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
Polymorphism allows for specifics to be dealt with during:

A)execution.
B)compilation.
C)programming.
D)debugging.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
For which of the following would polymorphism not provide a clean solution?

A)A billing program where there is a variety of client types that are billed with different fee structures.
B)A maintenance log program where data for a variety of types of machines is collected and maintenance schedules are produced for each machine based on the data collected.
C)A program to compute a 5% savings account interest for a variety of clients.
D)An IRS program that maintains information on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
All of the following methods are implicitly final except:

A)a method in an abstract class.
B)a private method.
C)a method declared in a final class.
D)static method.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
Assigning a subclass reference to a superclass variable is safe:

A)because the subclass object has an object of its superclass.
B)because the subclass object is an object of its superclass.
C)only when the superclass is abstract.
D)only when the superclass is concrete.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
Non-abstract classes are called:

A)real classes.
B)instance classes.
C)implementable classes.
D)concrete classes.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
Every object in Java knows its own class and can access this information through method .

A)getClass.
B)getInformation.
C)objectClass.
D)objectInformation.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
If the superclass contains only abstract method declarations,the superclass is used for:

A)implementation inheritance.
B)interface inheritance.
C)Both.
D)Neither.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)?

A)public int method1();
B)public int abstract method1();
C)public abstract int method1();
D)public int nonfinal method1();
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
It is a UML convention to denote the name of an abstract class in:

A)bold.
B)italics.
C)a diamond.
D)there is no convention of the UML to denote abstract classes-they are listed just as any other class.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following does not complete the sentence correctly? An interface .

A)forces classes that implement it to declare all the interface methods.
B)can be used in place of an abstract class when there is no default implementation to inherit.
C)is declared in a file by itself and is saved in a file with the same name as the interface followed by the .java extension.
D)can be instantiated.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following statements about interfaces is false?

A)An interface describes a set of methods that can be called on an object,providing a default implementation for the methods.
B)An interface describes a set of methods that can be called on an object,not providing concrete implementation for the methods.
C)Interfaces are useful when attempting to assign common functionality to possibly unrelated classes.
D)Once a class implements an interface,all objects of that class have an is-a relationship with the interface type.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
Declaring a method final means:

A)it will prepare the object for garbage collection.
B)it cannot be accessed from outside its class.
C)it cannot be overloaded.
D)it cannot be overridden.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
A class that implements an interface but does not declare all of the interface's methods must be declared:

A)public.
B)interface.
C)abstract.
D)final.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following is not possible?

A)A class that implements two interfaces.
B)A class that inherits from two classes.
C)A class that inherits from one class,and implements an interface.
D)All of the above are possible.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
The UML distinguishes an interface from other classes by placing the word "interface" in above the interface name.

A)italics.
B)carets.
C)guillemets.
D)bold.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
Interfaces can have methods.

A)0
B)1
C)2
D)any number of
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
Which keyword is used to specify that a class will define the methods of an interface?

A)uses.
B)implements.
C)defines.
D)extends.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.