Welcome to the C# Inheritance Quiz! This quiz is designed to test your knowledge of one of the core concepts in object-oriented programming: inheritance. Inheritance allows classes to inherit properties and behaviors from other classes, enabling code reuse and extending functionality. You will explore topics such as base classes, subclasses, method overriding, the use of the base
and override
keywords, and how inheritance hierarchies work in C#.
1.
What is the primary benefit of inheritance in C#?
2.
What is a base class in C# inheritance?
3.
What is a subclass in C#?
4.
Which of the following is true about C# inheritance?
5.
How do you indicate that a class is inheriting from another class in C#?
6.
What does the 'base' keyword do in a subclass constructor?
7.
What is the purpose of overriding a method in a subclass?
8.
What keyword must be used in the base class method to allow it to be overridden?
9.
What keyword is used in the subclass to override a method from the base class?
10.
What is the purpose of the 'base' keyword when calling a method from the base class?
11.
In the following class declaration, what is the role of 'SavingsAccount : BankAccount'?
public class SavingsAccount : BankAccount
12.
Which of the following is true about constructors in inheritance?
13.
Which of the following is required to override a method?
14.
What happens if you do not use the 'override' keyword when trying to override a method in C#?
15.
Which class is at the top of the class hierarchy in C#?
16.
What is single inheritance in C#?
17.
What is one benefit of method overriding in inheritance?