Deck 12: Object-Oriented Programming: Polymorphism

Full screen (f)
exit full mode
Question
Unfortunately,polymorphic programs make it difficult to add new capabilities to a system.
Use Space or
up arrow
down arrow
to flip the card.
Question
Polymorphism allows the addition of classes providing they were at least considered during program development.
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
Concrete classes provide implementations for every method and property they define.
Question
Abstract classes may not be:

A) inherited
B) accessed by derived-classes
C) instantiated
D) None of the above.
Question
Polymorphism allows classes to be added with little or no modifications to the generic portion of a program.
Question
Polymorphism helps promote software extensibility.
Question
Which statement best describes the relationship between base class and derived class types

A)A derived class reference cannot be assigned to a base class variable and a base class
Reference cannot be assigned to a derived class variable.
B)A derived class reference can be assigned to a base class variable and a base class
Reference can be assigned to a derived class variable.
C)A base class reference can be assigned to a derived class variable,but a derived class
Reference cannot be assigned to a base class variable.
D)A derived class reference can be assigned to a base class variable,but a base class
Reference cannot be assigned to a derived class variable.
Question
Which of the following is false about interfaces

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, without 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
When a request is made to use a derived-class-object method through a base-class reference,C# polymorphically chooses the correct overridden method in the appro
priate derived class that's associated with the object.
Question
Polymorphism allows for specifics to be dealt with during:

A)execution
B)compilation
C)programming
D)debugging
Question
The abstract methods and properties of a class do not provide an implementation.
Question
If a derived class reference is assigned to a base class variable,the variable must be cast back to the derived class before any derived class methods can be called with it.
Question
Polymorphism allows you to command a wide variety of objects even if you do not know the objects' types.
Question
Polymorphism enables objects of different classes that are related by a class hierarchy to be processed generically.
Question
If an app needs to perform a derived-class-specific operation on a derived class object reference by a base class variable,the app must first cast the base class reference to a derived class reference through a technique known as _________.

A) downcasting
D) increasecasting
Question
Polymorphism specifically enables the creation of programs that handle:

A) classes that are containers for other classes
B) large amounts of data with efficiency
C) a wide variety of classes in a general manner
D) None of the above
Question
When used correctly,polymorphism will never require changes to be made to any part of the program.
Question
The major drawback to polymorphically designed programs is that they do not take into account the future addition or deletion of classes.
Question
Polymorphism involves:

A) the same message sent to a variety of objects, which each interpret their own way
B) a specific message sent to each specific object
C) different messages sent to one object
D) None of the above.
Question
An abstract class cannot have instance data and non-abstract methods.
Question
Assigning a derived class reference to a base class variable is safe:

A)because the derived class has an object of its base class.
B)because the derived class is an object of its base class.
C)only when the base class is abstract.
D)only when the base class is concrete.
Question
You may define implementations for abstract methods to act as default implementations.
Question
Consider the abstract class below:
Public abstract class Foo
{
Private int a;
Public int b;
Public Foo(int aVal,int bVal)
{
A = aVal;
B = bVal;
}
Public abstract int calculate();
}
Any concrete subclass that extends class Foo:

A) Must implement a method called calculate.
B) Will not be able to access the instance variable a.
C) Will not be able to instantiate an object of class Foo.
D) All of the above.
Question
Operator is returns true if two matching types are being compared.
Question
The keyword sealed is applied to methods and classes to:

A) prevent overriding and inheritance
B) guarantee an implementation exists
C) specify a class is concrete
D) None of the above.
Question
Classes and methods are declared sealed for all of the following reasons,except:

A) sealed methods allow inlining the code.
B) sealed methods and classes prevent further inheritance.
C) sealed methods are static.
D) sealed methods can improve performance.
Question
An abstract base class can be used to declare references.
Question
An abstract class may be derived from another abstract class.
Question
Which of the following statements about abstract base classes is true

A) abstract base classes may contain data.
B) abstract base classes may not contain implementations of methods.
C) abstract base classes must declare all methods as abstract.
D) abstract base classes must declare all data members not given values as abstract.
Question
A convention of the UML is 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
If the base class contains only abstract method declarations,the base class is used for:

A) implementation inheritance.
B) interface inheritance.
C) Both.
D) Neither.
Question
All methods in an abstract class are inherently abstract.
Question
________ code is the process by which the compiler replaces method calls with the code of a method to improve performance.

A) Debugging
B) Inlining
C) Compiling
D) None of the above.
Question
If a method needs to be called polymorphically,what type of reference should be used to point to the object that the method is being called with

A) a reference of the base class that defines the behavior of the object
B) a reference of the same type as the object
C) an object reference to the actual object
D) None of the above.
Question
Attempting to instantiate an object of an abstract class is a logic error.
Question
Which declaration declares 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
Objects of abstract base classes can be instantiated.
Question
Every object in C# knows its own class and can access this information through method

A) GetType()
B) GetInformation()
C) ObjectClass()
D) ObjectInformation()
Question
The abstract keyword has the same effect as the virtual keyword.
Question
Sealing methods allows the compiler to optimize the program by "inlining code."
Question
Declaring a method sealed 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
Which of the following characteristics could be used to create an interface for a file,a cat and a house

A) door
B) tail
C) age
D) None of the above.
Question
A(n)________ is best used for providing services that bring together objects of otherwise unrelated classes.

A) abstract class
B) concrete class
C) interface
D) None of the above.
Question
A concrete class that implements an interface must define all methods and properties of that interface.
Question
Abstract classes can provide data and services for objects.
Question
Interfaces can have methods.

A) 0
B) 1
C) 2
D) any number of
Question
By convention,the name for a Car interface is:

A) InterfaceCar
B) ICar
C) CarI
D) None of the above.
Question
Constants declared in an interface are implicitly _______.

A)private.
B)static.
C)abstract.
D)All of the above.
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) is used in place of an abstract class when there is no default implementation to inherit.
C) cannot be instantiated.
D) can be instantiated.
Question
All methods in a sealed class must be explicitly declared sealed.
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
All static and private methods are implicitly sealed.
Question
An interface is typically used in place of an abstract class when there is no default implementation to inherit.
Question
Declaring an interface protected allows for extra security precautions.
Question
The purpose of an interface is to:

A) provide similar objects with the same functionality, even though each will imple
B) provide different types of objects with the comparable functionality, even though each will imple
C) provide default implementations of methods and properties
D) None of the above.
Question
Which is used to specify that a class will be implementing an interface

A) using
B) :
C) implements
D) extends
Question
If a class leaves one method in an interface undeclared,the class is implicitly declared by C# as an abstract class.
Question
An interface can not provide properties with get and set accessors.
Question
All of the following methods are implicitly sealed except:

A) a method in an abstract class.
B) a private method.
C) a method declared in a sealed class.
D) static method.
Question
A class that implements an interface may not act as a base class for other classes.
Question
An interface reference may invoke only the methods that the interface declares.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/62
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 12: Object-Oriented Programming: Polymorphism
1
Unfortunately,polymorphic programs make it difficult to add new capabilities to a system.
False
Polymorphic programs make it easy to add new capabilities to a system.
2
Polymorphism allows the addition of classes providing they were at least considered during program development.
False
Polymorphism can be used to include classes that were not even envisioned during program development.
3
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
4
Concrete classes provide implementations for every method and property they define.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
5
Abstract classes may not be:

A) inherited
B) accessed by derived-classes
C) instantiated
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
6
Polymorphism allows classes to be added with little or no modifications to the generic portion of a program.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
7
Polymorphism helps promote software extensibility.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
8
Which statement best describes the relationship between base class and derived class types

A)A derived class reference cannot be assigned to a base class variable and a base class
Reference cannot be assigned to a derived class variable.
B)A derived class reference can be assigned to a base class variable and a base class
Reference can be assigned to a derived class variable.
C)A base class reference can be assigned to a derived class variable,but a derived class
Reference cannot be assigned to a base class variable.
D)A derived class reference can be assigned to a base class variable,but a base class
Reference cannot be assigned to a derived class variable.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is false about interfaces

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, without 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 62 flashcards in this deck.
Unlock Deck
k this deck
10
When a request is made to use a derived-class-object method through a base-class reference,C# polymorphically chooses the correct overridden method in the appro
priate derived class that's associated with the object.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
11
Polymorphism allows for specifics to be dealt with during:

A)execution
B)compilation
C)programming
D)debugging
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
12
The abstract methods and properties of a class do not provide an implementation.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
13
If a derived class reference is assigned to a base class variable,the variable must be cast back to the derived class before any derived class methods can be called with it.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
14
Polymorphism allows you to command a wide variety of objects even if you do not know the objects' types.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
15
Polymorphism enables objects of different classes that are related by a class hierarchy to be processed generically.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
16
If an app needs to perform a derived-class-specific operation on a derived class object reference by a base class variable,the app must first cast the base class reference to a derived class reference through a technique known as _________.

A) downcasting
D) increasecasting
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
17
Polymorphism specifically enables the creation of programs that handle:

A) classes that are containers for other classes
B) large amounts of data with efficiency
C) a wide variety of classes in a general manner
D) None of the above
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
18
When used correctly,polymorphism will never require changes to be made to any part of the program.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
19
The major drawback to polymorphically designed programs is that they do not take into account the future addition or deletion of classes.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
20
Polymorphism involves:

A) the same message sent to a variety of objects, which each interpret their own way
B) a specific message sent to each specific object
C) different messages sent to one object
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
21
An abstract class cannot have instance data and non-abstract methods.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
22
Assigning a derived class reference to a base class variable is safe:

A)because the derived class has an object of its base class.
B)because the derived class is an object of its base class.
C)only when the base class is abstract.
D)only when the base class is concrete.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
23
You may define implementations for abstract methods to act as default implementations.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
24
Consider the abstract class below:
Public abstract class Foo
{
Private int a;
Public int b;
Public Foo(int aVal,int bVal)
{
A = aVal;
B = bVal;
}
Public abstract int calculate();
}
Any concrete subclass that extends class Foo:

A) Must implement a method called calculate.
B) Will not be able to access the instance variable a.
C) Will not be able to instantiate an object of class Foo.
D) All of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
25
Operator is returns true if two matching types are being compared.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
26
The keyword sealed is applied to methods and classes to:

A) prevent overriding and inheritance
B) guarantee an implementation exists
C) specify a class is concrete
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
27
Classes and methods are declared sealed for all of the following reasons,except:

A) sealed methods allow inlining the code.
B) sealed methods and classes prevent further inheritance.
C) sealed methods are static.
D) sealed methods can improve performance.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
28
An abstract base class can be used to declare references.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
29
An abstract class may be derived from another abstract class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following statements about abstract base classes is true

A) abstract base classes may contain data.
B) abstract base classes may not contain implementations of methods.
C) abstract base classes must declare all methods as abstract.
D) abstract base classes must declare all data members not given values as abstract.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
31
A convention of the UML is 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 62 flashcards in this deck.
Unlock Deck
k this deck
32
If the base class contains only abstract method declarations,the base class is used for:

A) implementation inheritance.
B) interface inheritance.
C) Both.
D) Neither.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
33
All methods in an abstract class are inherently abstract.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
34
________ code is the process by which the compiler replaces method calls with the code of a method to improve performance.

A) Debugging
B) Inlining
C) Compiling
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
35
If a method needs to be called polymorphically,what type of reference should be used to point to the object that the method is being called with

A) a reference of the base class that defines the behavior of the object
B) a reference of the same type as the object
C) an object reference to the actual object
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
36
Attempting to instantiate an object of an abstract class is a logic error.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
37
Which declaration declares 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 62 flashcards in this deck.
Unlock Deck
k this deck
38
Objects of abstract base classes can be instantiated.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
39
Every object in C# knows its own class and can access this information through method

A) GetType()
B) GetInformation()
C) ObjectClass()
D) ObjectInformation()
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
40
The abstract keyword has the same effect as the virtual keyword.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
41
Sealing methods allows the compiler to optimize the program by "inlining code."
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
42
Declaring a method sealed 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 62 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following characteristics could be used to create an interface for a file,a cat and a house

A) door
B) tail
C) age
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
44
A(n)________ is best used for providing services that bring together objects of otherwise unrelated classes.

A) abstract class
B) concrete class
C) interface
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
45
A concrete class that implements an interface must define all methods and properties of that interface.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
46
Abstract classes can provide data and services for objects.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
47
Interfaces can have methods.

A) 0
B) 1
C) 2
D) any number of
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
48
By convention,the name for a Car interface is:

A) InterfaceCar
B) ICar
C) CarI
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
49
Constants declared in an interface are implicitly _______.

A)private.
B)static.
C)abstract.
D)All of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
50
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) is used in place of an abstract class when there is no default implementation to inherit.
C) cannot be instantiated.
D) can be instantiated.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
51
All methods in a sealed class must be explicitly declared sealed.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
52
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 62 flashcards in this deck.
Unlock Deck
k this deck
53
All static and private methods are implicitly sealed.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
54
An interface is typically used in place of an abstract class when there is no default implementation to inherit.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
55
Declaring an interface protected allows for extra security precautions.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
56
The purpose of an interface is to:

A) provide similar objects with the same functionality, even though each will imple
B) provide different types of objects with the comparable functionality, even though each will imple
C) provide default implementations of methods and properties
D) None of the above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
57
Which is used to specify that a class will be implementing an interface

A) using
B) :
C) implements
D) extends
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
58
If a class leaves one method in an interface undeclared,the class is implicitly declared by C# as an abstract class.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
59
An interface can not provide properties with get and set accessors.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
60
All of the following methods are implicitly sealed except:

A) a method in an abstract class.
B) a private method.
C) a method declared in a sealed class.
D) static method.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
61
A class that implements an interface may not act as a base class for other classes.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
62
An interface reference may invoke only the methods that the interface declares.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 62 flashcards in this deck.