Deck 10: Introduction to 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
Match between columns
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/42
Play
Full screen (f)
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
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
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
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"
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
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
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
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
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
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
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
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
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
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
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
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
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
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()
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
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
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
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
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