C Sharp Inheritance Questions and Answers

Take Exam

C# Inheritance questions with answers are key for understanding object-oriented programming concepts in C#. Inheritance allows one class to acquire properties and methods of another, promoting code reusability and modular design. These programming questions and answers with explanations are often featured in technical interview Q&A for companies like Microsoft, Cognizant, and TCS. Practicing C# MCQs on inheritance helps learners grasp concepts like base and derived classes, access modifiers, method overriding, and polymorphism. Regular practice using C# programming interview questions with answers ensures strong command over object-oriented design principles for both academic and professional success.

C Sharp Inheritance

Showing 10 of 29 questions

1. Which of the following can be facilitated by the Inheritance mechanism?     Use the existing functionality of base class.     Overrride the existing functionality of base class.     Implement new functionality in the derived class.     Implement polymorphic behaviour.     Implement containership.

  • 1, 2, 3
  • 3, 4
  • 2, 4, 5
  • 3, 5
Show Answer Report

2. Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13? class BaseClass {     protected int i = 13; } class Derived: BaseClass {     int i = 9;     public void fun()     {         // [*** Add statement here ***]     } }

  • Console.WriteLine(base.i + " " + i);
  • Console.WriteLine(i + " " + base.i);
  • Console.WriteLine(mybase.i + " " + i);
  • Console.WriteLine(i + " " + mybase.i);
Show Answer Report

3. Which of the following should be used to implement a 'Has a' relationship between two entities?

  • Polymorphism
  • Templates
  • Containership
  • Encapsulation
Show Answer Report

4. In an inheritance chain which of the following members of base class are accessible to the derived class members?     static     protected     private     shared     public

  • 1, 3
  • 2, 5
  • 3, 4
  • 4, 5
Show Answer Report

5. Which of the following are reuse mechanisms available in C#.NET?     Inheritance     Encapsulation     Templates     Containership     Polymorphism

  • 1, 4
  • 1, 3
  • 2, 4
  • 3, 5
Show Answer Report

6. Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?

  • Polymorphism
  • Containership
  • Templates
  • Encapsulation
Show Answer Report

7. Which of the following is the correct way to create an object of the class Sample?

  • Declare the existing class as shadows.
  • Declare the existing class as overloads.
  • Declare the existing class as sealed.
  • Declare the existing class as suppress.
Show Answer Report

8. Which of the following statements are correct about Inheritance in C#.NET?     A derived class object contains all the base class data.     Inheritance cannot suppress the base class functionality.     A derived class may not be able to access all the base class data.     Inheritance cannot extend the base class functionality.     In inheritance chain construction of object happens from base towards derived.

  • 1, 2, 4
  • 2, 4, 5
  • 1, 3, 5
  • 2, 4
Show Answer Report

9. Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?

  • While creating the object firstly the constructor of class B will be called followed by constructor of class A.
  • While creating the object firstly the constructor of class A will be called followed by constructor of class B.
  • The constructor of only class B will be called.
  • The constructor of only class A will be called.
Show Answer Report

10. Which of the following is NOT a type of inheritance in C#?

  • Single inheritance
  • Multiple inheritance
  • Hybrid inheritance
  • Multilevel inheritance
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test