Deck 10: Introduction to Inheritance

Full screen (f)
exit full mode
Question
When you declare a property defined in a base class as override in a derived class, this new declaration overrides and ____ its counterpart in the parent class.

A) eliminates
B) removes
C) uses
D) hides
Use Space or
up arrow
down arrow
to flip the card.
Question
The Equals() method compares two objects and returns true if they have the same value.
Question
A class that inherits from a base class is a ____.

A) base class
B) derived class
C) superclass
D) parent class
Question
A class that is used as a basis for inheritance is called a(n) ____.

A) child class
B) extended class
C) base class
D) subclass
Question
When presented with two classes that have a parent-child relationship, you can tell which class is the base class and which is the derived class by using the two classes in a sentence with the phrase ____.

A) "is a"
B) "in a"
C) "of a"
D) "uses a"
Question
A ____ is a synonym for a derived class.

A) parent class
B) superclass
C) base class
D) subclass
Question
When a derived class contains a method that overrides a parent class method, you can use the keyword ____ to access the parent class method from within the derived class.

A) base
B) super
C) upper
D) parent
Question
A(n) ____ data field or method can be used within its own class or in any classes extended from that class, but it cannot be used by "outside" classes.

A) protected
B) public
C) private
D) internal
Question
A ____ is a synonym for a derived class.

A) parent class
B) second class
C) base class
D) child class
Question
A base class member that is not hidden by the derived class is ____ in the derived class.

A) overridden
B) removed
C) visible
D) eliminated
Question
In C#, you can use either new or ____ when defining a derived class member that has the same name as a base class member.

A) cast
B) hide
C) override
D) overload
Question
If a base class and a derived class have methods with the same names but different parameter lists, the derived class method overrides the base class method.
Question
A superclass contains all the fields and methods of its subclasses as well as its own more specific fields and methods.
Question
You can assign a derived class object to an object of any of its superclass types. When you do, C# makes a(n) ____ conversion from derived class to base class.

A) explicit
B) implicit
C) real
D) strong
Question
Every class you create in C# derives from a single class named ____.

A) System.Console
B) System.Object
C) System.Class
D) Object.System
Question
The keyword ____ is an alias for the System.Object class.

A) object
B) base
C) super
D) parent
Question
When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your data will be altered only by the properties and methods you choose and only in ways that you can control.
Question
A class's ToString() method is often a useful debugging aid.
Question
A(n) ____ is a synonym for a base class.

A) derived class
B) parent class
C) extended class
D) child class
Question
Classes that depend on field names from parent classes are said to be ____ because they are prone to errors.

A) solid
B) fixed
C) fragile
D) sound
Question
What are the requirements for overloading the Object class's Equals() method?
Question
____________________ are methods that you can write to add to any type, even if you did not create the original class.
Question
Explain the sequence of constructors that will be called when you create an object that is an instance of a derived class.
Question
Briefly describe the four public instance methods of the Object class.
Question
Inheritance is ____________________, which means a child inherits all the members of all its ancestors.
Question
The keyword ____ always refers to the superclass of the class in which you use it.

A) super
B) parent
C) upper
D) base
Question
The ability to inherit from more than one class is called ____.

A) polymorphism
B) interfacing
C) collaboration
D) multiple inheritance
Question
The ____ Object class method returns a string that holds the name of the class, just as GetType() does.

A) GetHashCode()
B) Equals()
C) GetName()
D) ToString()
Question
A(n) ____ method has no method statements; any class derived from a class that contains one must override it by providing a body.

A) concrete
B) overloaded
C) abstract
D) overridden
Question
A ____ is sometimes called a "fingerprint" for an object because it uniquely identifies the object.

A) property
B) hash code
C) derived code
D) new property
Question
A(n) ____________________ method is one that can be overridden by a method with the same signature in a child class.
Question
When a derived class contains a method or property that overrides a parent class method or property, how can you use the parent class version from within the subclass? Show an example of a derived class that overrides a parent class method, but then uses the parent class method.
Question
On some occasions, you might want to access parent class data from a child class. Declaring the parent class field as public would violate the principle of information hiding, but declaring it private would make it inaccessible. How can the proper level of security be achieved?
Question
A(n) ____ class is one from which you cannot create concrete objects, but from which you can inherit.

A) abstract
B) concrete
C) base
D) derived
Question
The entire list of parent classes from which a child class is derived constitutes the ____________________ of the subclass.
Question
Show an example of a class definition that creates a subclass of an existing Employee class, and adds a private double field called commissionRate . What is the total set of fields that an instance of the new class contains?
Question
The ability to inherit from more than one class is called multiple inheritance. C# prohibits multiple inheritance, but it does provide an alternative mechanism. Why is multiple inheritance prohibited, and what is the alternative that is provided?
Question
C# makes implicit conversions when casting one data type to another. When a derived class object is assigned to its ancestor's data type, the conversion can more specifically be called a(n) ___________________________________.
Question
Briefly describe the similarities and differences between abstract classes and interfaces.
Question
When all base class constructors require arguments, you must include a constructor for each derived class you create. Why?
Question
Match between columns
The ultimate base class for all other types
System.Object
The ultimate base class for all other types
extended class
The ultimate base class for all other types
Equals()
The ultimate base class for all other types
GetType()
The ultimate base class for all other types
reference equality
The ultimate base class for all other types
polymorphism
The ultimate base class for all other types
superclass
The ultimate base class for all other types
sealed class
The ultimate base class for all other types
protected members
Using the same method name to indicate different implementations
System.Object
Using the same method name to indicate different implementations
extended class
Using the same method name to indicate different implementations
Equals()
Using the same method name to indicate different implementations
GetType()
Using the same method name to indicate different implementations
reference equality
Using the same method name to indicate different implementations
polymorphism
Using the same method name to indicate different implementations
superclass
Using the same method name to indicate different implementations
sealed class
Using the same method name to indicate different implementations
protected members
Also known as a derived class
System.Object
Also known as a derived class
extended class
Also known as a derived class
Equals()
Also known as a derived class
GetType()
Also known as a derived class
reference equality
Also known as a derived class
polymorphism
Also known as a derived class
superclass
Also known as a derived class
sealed class
Also known as a derived class
protected members
Returns true if two Object s have the same memory address
System.Object
Returns true if two Object s have the same memory address
extended class
Returns true if two Object s have the same memory address
Equals()
Returns true if two Object s have the same memory address
GetType()
Returns true if two Object s have the same memory address
reference equality
Returns true if two Object s have the same memory address
polymorphism
Returns true if two Object s have the same memory address
superclass
Returns true if two Object s have the same memory address
sealed class
Returns true if two Object s have the same memory address
protected members
A synonym for base class
System.Object
A synonym for base class
extended class
A synonym for base class
Equals()
A synonym for base class
GetType()
A synonym for base class
reference equality
A synonym for base class
polymorphism
A synonym for base class
superclass
A synonym for base class
sealed class
A synonym for base class
protected members
Can be used by a class and its descendants
System.Object
Can be used by a class and its descendants
extended class
Can be used by a class and its descendants
Equals()
Can be used by a class and its descendants
GetType()
Can be used by a class and its descendants
reference equality
Can be used by a class and its descendants
polymorphism
Can be used by a class and its descendants
superclass
Can be used by a class and its descendants
sealed class
Can be used by a class and its descendants
protected members
A class that cannot be extended
System.Object
A class that cannot be extended
extended class
A class that cannot be extended
Equals()
A class that cannot be extended
GetType()
A class that cannot be extended
reference equality
A class that cannot be extended
polymorphism
A class that cannot be extended
superclass
A class that cannot be extended
sealed class
A class that cannot be extended
protected members
Returns a string containing an object's class
System.Object
Returns a string containing an object's class
extended class
Returns a string containing an object's class
Equals()
Returns a string containing an object's class
GetType()
Returns a string containing an object's class
reference equality
Returns a string containing an object's class
polymorphism
Returns a string containing an object's class
superclass
Returns a string containing an object's class
sealed class
Returns a string containing an object's class
protected members
Occurs when two reference type objects refer to the same object
System.Object
Occurs when two reference type objects refer to the same object
extended class
Occurs when two reference type objects refer to the same object
Equals()
Occurs when two reference type objects refer to the same object
GetType()
Occurs when two reference type objects refer to the same object
reference equality
Occurs when two reference type objects refer to the same object
polymorphism
Occurs when two reference type objects refer to the same object
superclass
Occurs when two reference type objects refer to the same object
sealed class
Occurs when two reference type objects refer to the same object
protected members
Question
Reusing existing classes and interfaces makes the job of programming easier. What are some of the future advantages that come from writing extendable base classes?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Introduction to Inheritance
1
When you declare a property defined in a base class as override in a derived class, this new declaration overrides and ____ its counterpart in the parent class.

A) eliminates
B) removes
C) uses
D) hides
D
2
The Equals() method compares two objects and returns true if they have the same value.
False
3
A class that inherits from a base class is a ____.

A) base class
B) derived class
C) superclass
D) parent class
B
4
A class that is used as a basis for inheritance is called a(n) ____.

A) child class
B) extended class
C) base class
D) subclass
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
5
When presented with two classes that have a parent-child relationship, you can tell which class is the base class and which is the derived class by using the two classes in a sentence with the phrase ____.

A) "is a"
B) "in a"
C) "of a"
D) "uses a"
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
6
A ____ is a synonym for a derived class.

A) parent class
B) superclass
C) base class
D) subclass
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
7
When a derived class contains a method that overrides a parent class method, you can use the keyword ____ to access the parent class method from within the derived class.

A) base
B) super
C) upper
D) parent
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
8
A(n) ____ data field or method can be used within its own class or in any classes extended from that class, but it cannot be used by "outside" classes.

A) protected
B) public
C) private
D) internal
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
9
A ____ is a synonym for a derived class.

A) parent class
B) second class
C) base class
D) child class
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
10
A base class member that is not hidden by the derived class is ____ in the derived class.

A) overridden
B) removed
C) visible
D) eliminated
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
11
In C#, you can use either new or ____ when defining a derived class member that has the same name as a base class member.

A) cast
B) hide
C) override
D) overload
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
12
If a base class and a derived class have methods with the same names but different parameter lists, the derived class method overrides the base class method.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
13
A superclass contains all the fields and methods of its subclasses as well as its own more specific fields and methods.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
14
You can assign a derived class object to an object of any of its superclass types. When you do, C# makes a(n) ____ conversion from derived class to base class.

A) explicit
B) implicit
C) real
D) strong
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
15
Every class you create in C# derives from a single class named ____.

A) System.Console
B) System.Object
C) System.Class
D) Object.System
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
16
The keyword ____ is an alias for the System.Object class.

A) object
B) base
C) super
D) parent
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
17
When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your data will be altered only by the properties and methods you choose and only in ways that you can control.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
18
A class's ToString() method is often a useful debugging aid.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
19
A(n) ____ is a synonym for a base class.

A) derived class
B) parent class
C) extended class
D) child class
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
20
Classes that depend on field names from parent classes are said to be ____ because they are prone to errors.

A) solid
B) fixed
C) fragile
D) sound
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
21
What are the requirements for overloading the Object class's Equals() method?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
22
____________________ are methods that you can write to add to any type, even if you did not create the original class.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
23
Explain the sequence of constructors that will be called when you create an object that is an instance of a derived class.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
24
Briefly describe the four public instance methods of the Object class.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
25
Inheritance is ____________________, which means a child inherits all the members of all its ancestors.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
26
The keyword ____ always refers to the superclass of the class in which you use it.

A) super
B) parent
C) upper
D) base
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
27
The ability to inherit from more than one class is called ____.

A) polymorphism
B) interfacing
C) collaboration
D) multiple inheritance
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
28
The ____ Object class method returns a string that holds the name of the class, just as GetType() does.

A) GetHashCode()
B) Equals()
C) GetName()
D) ToString()
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
29
A(n) ____ method has no method statements; any class derived from a class that contains one must override it by providing a body.

A) concrete
B) overloaded
C) abstract
D) overridden
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
30
A ____ is sometimes called a "fingerprint" for an object because it uniquely identifies the object.

A) property
B) hash code
C) derived code
D) new property
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
31
A(n) ____________________ method is one that can be overridden by a method with the same signature in a child class.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
32
When a derived class contains a method or property that overrides a parent class method or property, how can you use the parent class version from within the subclass? Show an example of a derived class that overrides a parent class method, but then uses the parent class method.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
33
On some occasions, you might want to access parent class data from a child class. Declaring the parent class field as public would violate the principle of information hiding, but declaring it private would make it inaccessible. How can the proper level of security be achieved?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
34
A(n) ____ class is one from which you cannot create concrete objects, but from which you can inherit.

A) abstract
B) concrete
C) base
D) derived
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
35
The entire list of parent classes from which a child class is derived constitutes the ____________________ of the subclass.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
36
Show an example of a class definition that creates a subclass of an existing Employee class, and adds a private double field called commissionRate . What is the total set of fields that an instance of the new class contains?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
37
The ability to inherit from more than one class is called multiple inheritance. C# prohibits multiple inheritance, but it does provide an alternative mechanism. Why is multiple inheritance prohibited, and what is the alternative that is provided?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
38
C# makes implicit conversions when casting one data type to another. When a derived class object is assigned to its ancestor's data type, the conversion can more specifically be called a(n) ___________________________________.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
39
Briefly describe the similarities and differences between abstract classes and interfaces.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
40
When all base class constructors require arguments, you must include a constructor for each derived class you create. Why?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
The ultimate base class for all other types
System.Object
The ultimate base class for all other types
extended class
The ultimate base class for all other types
Equals()
The ultimate base class for all other types
GetType()
The ultimate base class for all other types
reference equality
The ultimate base class for all other types
polymorphism
The ultimate base class for all other types
superclass
The ultimate base class for all other types
sealed class
The ultimate base class for all other types
protected members
Using the same method name to indicate different implementations
System.Object
Using the same method name to indicate different implementations
extended class
Using the same method name to indicate different implementations
Equals()
Using the same method name to indicate different implementations
GetType()
Using the same method name to indicate different implementations
reference equality
Using the same method name to indicate different implementations
polymorphism
Using the same method name to indicate different implementations
superclass
Using the same method name to indicate different implementations
sealed class
Using the same method name to indicate different implementations
protected members
Also known as a derived class
System.Object
Also known as a derived class
extended class
Also known as a derived class
Equals()
Also known as a derived class
GetType()
Also known as a derived class
reference equality
Also known as a derived class
polymorphism
Also known as a derived class
superclass
Also known as a derived class
sealed class
Also known as a derived class
protected members
Returns true if two Object s have the same memory address
System.Object
Returns true if two Object s have the same memory address
extended class
Returns true if two Object s have the same memory address
Equals()
Returns true if two Object s have the same memory address
GetType()
Returns true if two Object s have the same memory address
reference equality
Returns true if two Object s have the same memory address
polymorphism
Returns true if two Object s have the same memory address
superclass
Returns true if two Object s have the same memory address
sealed class
Returns true if two Object s have the same memory address
protected members
A synonym for base class
System.Object
A synonym for base class
extended class
A synonym for base class
Equals()
A synonym for base class
GetType()
A synonym for base class
reference equality
A synonym for base class
polymorphism
A synonym for base class
superclass
A synonym for base class
sealed class
A synonym for base class
protected members
Can be used by a class and its descendants
System.Object
Can be used by a class and its descendants
extended class
Can be used by a class and its descendants
Equals()
Can be used by a class and its descendants
GetType()
Can be used by a class and its descendants
reference equality
Can be used by a class and its descendants
polymorphism
Can be used by a class and its descendants
superclass
Can be used by a class and its descendants
sealed class
Can be used by a class and its descendants
protected members
A class that cannot be extended
System.Object
A class that cannot be extended
extended class
A class that cannot be extended
Equals()
A class that cannot be extended
GetType()
A class that cannot be extended
reference equality
A class that cannot be extended
polymorphism
A class that cannot be extended
superclass
A class that cannot be extended
sealed class
A class that cannot be extended
protected members
Returns a string containing an object's class
System.Object
Returns a string containing an object's class
extended class
Returns a string containing an object's class
Equals()
Returns a string containing an object's class
GetType()
Returns a string containing an object's class
reference equality
Returns a string containing an object's class
polymorphism
Returns a string containing an object's class
superclass
Returns a string containing an object's class
sealed class
Returns a string containing an object's class
protected members
Occurs when two reference type objects refer to the same object
System.Object
Occurs when two reference type objects refer to the same object
extended class
Occurs when two reference type objects refer to the same object
Equals()
Occurs when two reference type objects refer to the same object
GetType()
Occurs when two reference type objects refer to the same object
reference equality
Occurs when two reference type objects refer to the same object
polymorphism
Occurs when two reference type objects refer to the same object
superclass
Occurs when two reference type objects refer to the same object
sealed class
Occurs when two reference type objects refer to the same object
protected members
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
42
Reusing existing classes and interfaces makes the job of programming easier. What are some of the future advantages that come from writing extendable base classes?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 42 flashcards in this deck.