Deck 10: Object-Oriented Programming: Inheritance
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
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/82
Play
Full screen (f)
Deck 10: Object-Oriented Programming: Inheritance
1
A method must be declared __________ for it to be overridden by derived classes.
A)Overrides
B)Overridable
C)Virtual
D)None of the above
A)Overrides
B)Overridable
C)Virtual
D)None of the above
Overridable
2
All classes in Visual Basic have Object as either a direct or indirect base class.
True
3
Which of the following pairs demonstrates the "is-a" relationship?
A)car,engine
B)book,table of contents
C)baseball,sport
D)None of the above
A)car,engine
B)book,table of contents
C)baseball,sport
D)None of the above
C
4
To avoid duplicating code (and possibly errors),use ________,rather than ________.
A)inheritance,the "copy-and-paste" approach
B)the "copy-and-paste" approach,inheritance
C)a class that explicitly extends Object,a class that does not extend Object
D)a class that does not extend Object, a class that explicitly extends Object
A)inheritance,the "copy-and-paste" approach
B)the "copy-and-paste" approach,inheritance
C)a class that explicitly extends Object,a class that does not extend Object
D)a class that does not extend Object, a class that explicitly extends Object
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
5
__________ is a form of xe "code reuse"xe "software reuse"software reuse in which a new class is created quickly and easily by absorbing an existing class's members and customizing them with new or modified capabilities.
A)Interfacing
B)Inheritance
C)Encapsulating
D)Polymorphism
A)Interfacing
B)Inheritance
C)Encapsulating
D)Polymorphism
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
6
A base class's constructors are inherited into its derived classes.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following could be a base class for class Computer?
A)machine
B)hard-drive
C)software
D)keyboard
A)machine
B)hard-drive
C)software
D)keyboard
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
8
An advantage of inheritance is that:
A)all methods can be inherited
B)all instance variables can be uniformly accessed by base classes and derived classes
C)Objects of a derived class can be treated as objects of their base class
D)None of the above.
A)all methods can be inherited
B)all instance variables can be uniformly accessed by base classes and derived classes
C)Objects of a derived class can be treated as objects of their base class
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
9
A base class may have only one derived class.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
10
A derived class can add its own instance variables,Shared variables,properties and methods,and it can customize methods and properties it inherits.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
11
Every class in Visual Basic except __________ extends an existing class.
A)Integer
B)Object
C)Type
D)Class
A)Integer
B)Object
C)Type
D)Class
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
12
A base class is more specific than its derived class and represents a more specialized group of objects.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
13
Inheritance is represented by a(n)_________ relationship.
A)"uses"
B)"is-a"
C)"has-a"
D)None of the above.
A)"uses"
B)"is-a"
C)"has-a"
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is not a base/derived class relationship?
A)Ford/Taurus
B)University/Boston University
C)Sailboat/Tugboat
D)Country/USA
A)Ford/Taurus
B)University/Boston University
C)Sailboat/Tugboat
D)Country/USA
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
15
When creating a class,rather than declaring completely new members,you can designate that the new class inherits the members of an existing class.The existing class is called the __________ class,and the new class is the __________ class.
A)derived,base
B)root,child
C)sub,super
D)base,derived
A)derived,base
B)root,child
C)sub,super
D)base,derived
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
16
A class inherited from two or more levels up in the hierarchy is known as a(n) .
A)indirect base class
B)direct base class
C)superclass
D)None of the above
A)indirect base class
B)direct base class
C)superclass
D)None of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
17
The default implementation of method ToString of Object returns a String representing ________.
A)the object's type
B)the object class name
C)namespace_name.object_class_name
D)None of the above
A)the object's type
B)the object class name
C)namespace_name.object_class_name
D)None of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
18
Polymorphism enables you to conveniently xe "program in the general"program "in the general" rather than "xe "program in the specific"in the specific."
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following pairs demonstrates the "has-a" relationship?
A)car,vehicle
B)house,window
C)teacher,person
D)None of the above
A)car,vehicle
B)house,window
C)teacher,person
D)None of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
20
The class hierarchy begins with class __________.
A)Object
B)Point
C)Root
D)Base
A)Object
B)Point
C)Root
D)Base
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
21
When a program creates a derived-class object,the Object constructor is the last constructor called and the first whose body finishes executing.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
22
Polymorphism allows for specifics to be dealt with during:
A)execution
B)compilation
C)programming
D)debugging
A)execution
B)compilation
C)programming
D)debugging
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
23
How can a derived class constructor ccall a base class constructor?
A)implicitly
B)explicitly
C)a and b
D)the derived class cannot call the base class constructor
A)implicitly
B)explicitly
C)a and b
D)the derived class cannot call the base class constructor
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
24
For which of the following would polymorphism not provide a clean solution?
A)A billing program where there is a variety of clients who are billed with different fee structures.
B)A maintenance log program where a variety of machine data 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 bank 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.
A)A billing program where there is a variety of clients who are billed with different fee structures.
B)A maintenance log program where a variety of machine data 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 bank 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 82 flashcards in this deck.
Unlock Deck
k this deck
25
In practice,derived classes should depend only on the base-class services (that is,Private methods and properties)and not on the base-class data implementation.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
26
To call the base-class default constructor explicitly,the call to a base-class constructor must be the first statement in the derived-class-constructor definition.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
27
Which statement is true when a base class has Protected instance variables?
A)A derived class object can assign an invalid value to the base class's Protected instance variables.
B)Derived class methods can depend on the base class's Protected data implementation.
C)Derived classes would need to be modified if the base class's Protected data implementation changes.
D)All of the above.
A)A derived class object can assign an invalid value to the base class's Protected instance variables.
B)Derived class methods can depend on the base class's Protected data implementation.
C)Derived classes would need to be modified if the base class's Protected data implementation changes.
D)All of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
28
When a derived-class member overrides a base-class member,the base-class member can be accessed from the derived-class by using the Visual Basic keyword .
A)MyBase
B)Top
C)Super
D)None of the above
A)MyBase
B)Top
C)Super
D)None of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
29
When a request is made to use a derived-class-object method through a base-class reference,Visual Basic polymorphically chooses the correct overridden method in the derived class that is associated with the object.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
30
Polymorphism involves:
A)the same message sent to a variety of objects of types related by inheritance
B)a specific message sent to each specific object
C)different messages sent to one object
D)None of the above.
A)the same message sent to a variety of objects of types related by inheritance
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 82 flashcards in this deck.
Unlock Deck
k this deck
31
The first task of any base class's constructor is to call its derived class's constructor.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
32
With Protected instance variables in the base class,all the derived classes of the base class may need to be modified if the base-class implementation changes.In such a case,the software is said to be non-modifiable,because a small change in the base class can "break" derived-class implementations.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
33
Polymorphism allows the addition of classes providing they were at least considered during program development.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
34
Consider the classes below: 
Which of the statements below is false?
A)Both variables a and b are instance variables.
B)After the constructor for Class B executes,the variable a will have the value 7.
C)After the constructor for Class B executes,the variable b will have the value 8.
D)A reference to an object of Class A can be treated as a reference to an object of Class B.

Which of the statements below is false?
A)Both variables a and b are instance variables.
B)After the constructor for Class B executes,the variable a will have the value 7.
C)After the constructor for Class B executes,the variable b will have the value 8.
D)A reference to an object of Class A can be treated as a reference to an object of Class B.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
35
When a base class method is overridden in a derived class,it is common to have the derived class version call the base class version and then do some additional work.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
36
Base class methods with this level of access cannot be called from derived classes.
A)Private
B)Public
C)Protected
D)None of the above
A)Private
B)Public
C)Protected
D)None of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
37
A base class's method that's overridden in a derived class will be executed implicitly when the derived class's method is called.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
38
The Protected members of a base class may be accessed in their class or any classes derived from that base class.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
39
When a derived class constructor calls its base class constructor,what happens if the base class's constructor does not assign a value to one of its instance variables?
A)a syntax error occurs
B)a compile-time error occurs
C)a run-time error occurs
D)the instance variables are initialized to their default values
A)a syntax error occurs
B)a compile-time error occurs
C)a run-time error occurs
D)the instance variables are initialized to their default values
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
40
Private fields of a base class can be accessed in a derived class
A)by calling Private methods declared in the base class
B)by calling Public or Protected methods declared in the base class
C)directly
D)All of the above
A)by calling Private methods declared in the base class
B)by calling Public or Protected methods declared in the base class
C)directly
D)All of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
41
An abstract class cannot have instance data and non-abstract methods.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
42
Classes which may be instantiated are ___________ classes.
A)instance
B)concrete
C)abstract
D)None of the above
A)instance
B)concrete
C)abstract
D)None of the above
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
43
Abstract methods and properties do not provide an implementation.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
44
The use of polymorphism helps promote software extensibility.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
45
All methods in an abstract class are abstract.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
46
Which answer best describes how many interfaces a class can implement?
A)0
B)1
C)1 or more
D)0 or more
A)0
B)1
C)1 or more
D)0 or more
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
47
You may define implementations for abstract methods to act as a default.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
48
The MustOverride keyword has the same effect as the Overridable keyword.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
49
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.
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 82 flashcards in this deck.
Unlock Deck
k this deck
50
Objects of abstract base classes can be instantiated.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
51
Concrete classes provide implementations for at least one of the methods and properties they define.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
52
Abstract classes are classes which may not be:
A)inherited
B)accessed by derived-classes
C)instantiated
D)None of the above.
A)inherited
B)accessed by derived-classes
C)instantiated
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
53
Which of the following statements about MustInherit base classes is true?
A)MustInherit base classes may contain data.
B)MustInherit base classes may not contain implementations of methods.
C)MustInherit base classes must declare all methods as MustOverride.
D)MustInherit base classes must declare all data members not given values as MustOverride.
A)MustInherit base classes may contain data.
B)MustInherit base classes may not contain implementations of methods.
C)MustInherit base classes must declare all methods as MustOverride.
D)MustInherit base classes must declare all data members not given values as MustOverride.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
54
Once a class implements an interface,all objects of that class have a(n)__________ relationship with the interface type.
A)has a
B)equals
C)is a
D)composition
A)has a
B)equals
C)is a
D)composition
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
55
Consider the MustInherit base classes below: 
Any concrete subclass that inherits 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.

Any concrete subclass that inherits 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 82 flashcards in this deck.
Unlock Deck
k this deck
56
A class with MustOverride methods does not necessarily have to be a MustInherit class.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
57
Attempting to instantiate an object of an abstract class is a logic error.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
58
The _________ keyword is used to define methods within a MustInherit class that must be implemented in a derived class for that derived class to be concrete.
A)Overridable
B)Abstract
C)MustOverride
D)MustImplement.
A)Overridable
B)Abstract
C)MustOverride
D)MustImplement.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
59
Polymorphism allows you to command a wide variety of objects of types related by inheritance as long as you know the objects' types.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
60
The ________ keyword is used to create an abstract class.
A)Polymorph
B)Inherit
C)Abstract
D)MustInherit
A)Polymorph
B)Inherit
C)Abstract
D)MustInherit
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
61
An interface reference may invoke only the methods that the interface declares.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
62
All objects of a class are guaranteed to provide the functionality described by any interface that the class implements.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
63
A class that implements an interface must define all methods and properties of that interface.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
64
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
A)italics
B)carets
C)guillemets
D)bold
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
65
An interface may not provide properties with Get and Set accessors.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
66
Declaring an interface Protected allows for extra security precautions.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
67
By convention,the name for a Car interface is:
A)InterfaceCar
B)ICar
C)CarI
D)None of the above.
A)InterfaceCar
B)ICar
C)CarI
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
68
A(n)________ is particularly appropriate for providing services that disparate objects have in common.
A)abstract class
B)concrete class
C)interface
D)None of the above.
A)abstract class
B)concrete class
C)interface
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
69
To use an interface,a class must define only the methods in the interface that it will need to use.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
70
An interface is typically used in place of a MustInherit class when there is no default implementation to inherit.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
71
Which is used to specify that a class will be implementing an interface?
A)Using
B):
C)Implements
D)Extends.
A)Using
B):
C)Implements
D)Extends.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
72
If a class leaves one method in an interface undeclared,the class is implicitly declared by Visual Basic as a MustInherit class.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
73
A class that implements an interface but does not declare all of the interface's methods must be declared:
A)Public
B)Interface
C)MustInherit
D)Final
A)Public
B)Interface
C)MustInherit
D)Final
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
74
The purpose of an interface is to:
A)provide similar objects with the same functionality,even though each will implement the functionality differently
B)provide different objects with the same functionality,even though each will implement the functionality differently
C)provide default implementations of methods and properties
D)None of the above.
A)provide similar objects with the same functionality,even though each will implement the functionality differently
B)provide different objects with the same functionality,even though each will implement the functionality differently
C)provide default implementations of methods and properties
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
75
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 MustInherit class when there is no default implementation to inherit.
C)cannot be instantiated.
D)can be instantiated.
An interface _____________.
A)forces classes that implement it to declare all the interface methods.
B)is used in place of an MustInherit class when there is no default implementation to inherit.
C)cannot be instantiated.
D)can be instantiated.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
76
An interface is defined with keyword _________.
A)Interface
B)MustInherit
C)Implements
D)Abstract
A)Interface
B)MustInherit
C)Implements
D)Abstract
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
77
Which of the following properties could exist in an interface for files,cats and houses?
A)door
B)tail
C)age
D)None of the above.
A)door
B)tail
C)age
D)None of the above.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
78
Interfaces can have__________ methods.
A)0
B)1
C)2
D)any number of
A)0
B)1
C)2
D)any number of
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
79
Objects of unrelated classes that implement the same interface can respond to the method calls of that interface polymorphically.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck
80
A class that implements an interface may not act as a base class for other classes.
Unlock Deck
Unlock for access to all 82 flashcards in this deck.
Unlock Deck
k this deck