C Sharp Inheritance Questions and Answers
Practice ModeShowing 10 of 29 questions
Q11
What keyword is used to implement inheritance in C#?
Answer: Option D
Explanation: The colon (:) symbol is used to implement inheritance between classes in C#.
Q12
Which class cannot be inherited in C#?
Answer: Option B
Explanation: Sealed classes are designed to prevent inheritance in C#.
Q13
What is the root class of all classes in C#?
Answer: Option C
Explanation: Object class is the ultimate base class for all classes in the .NET Framework.
Q14
Which access modifier allows a member to be accessible only within its own class and derived classes?
Answer: Option D
Explanation: Protected members are accessible within the class and by derived class instances.
Q15
What keyword is used to call the base class constructor from a derived class?
Answer: Option C
Explanation: The base keyword is used to call base class constructors and methods.
Q16
Which of the following is true about abstract classes?
Answer: Option D
Explanation: Abstract classes cannot be instantiated and must be inherited.
Q17
What is the main purpose of the "virtual" keyword in C#?
Answer: Option C
Explanation: Virtual keyword allows methods to be overridden in derived classes.
Q18
Which keyword is used to override a method in a derived class?
Answer: Option C
Explanation: Override keyword explicitly indicates that a method is intended to override a base class method.
Q19
What happens if a class does not explicitly inherit from any class?
Answer: Option B
Explanation: In C#, all classes implicitly inherit from Object class if no explicit inheritance is specified.
Q20
Which of the following can implement multiple inheritance in C#?
Answer: Option C
Explanation: Interfaces allow a class to implement multiple inheritance in C#.