C Sharp Inheritance Questions and Answers

Practice Mode
Showing 10 of 29 questions
Q1
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.
  • A 1, 2, 3
  • B 3, 4
  • C 2, 4, 5
  • D 3, 5
Answer: Option A
Q2
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 ***]     } }
  • A Console.WriteLine(base.i + " " + i);
  • B Console.WriteLine(i + " " + base.i);
  • C Console.WriteLine(mybase.i + " " + i);
  • D Console.WriteLine(i + " " + mybase.i);
Answer: Option B
Q3
Which of the following should be used to implement a 'Has a' relationship between two entities?
  • A Polymorphism
  • B Templates
  • C Containership
  • D Encapsulation
Answer: Option C
Q4
In an inheritance chain which of the following members of base class are accessible to the derived class members?     static     protected     private     shared     public
  • A 1, 3
  • B 2, 5
  • C 3, 4
  • D 4, 5
Answer: Option B
Q5
Which of the following are reuse mechanisms available in C#.NET?     Inheritance     Encapsulation     Templates     Containership     Polymorphism
  • A 1, 4
  • B 1, 3
  • C 2, 4
  • D 3, 5
Answer: Option A
Q6
Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?
  • A Polymorphism
  • B Containership
  • C Templates
  • D Encapsulation
Answer: Option
Q7
Which of the following is the correct way to create an object of the class Sample?
  • A Declare the existing class as shadows.
  • B Declare the existing class as overloads.
  • C Declare the existing class as sealed.
  • D Declare the existing class as suppress.
Answer: Option C
Q8
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.
  • A 1, 2, 4
  • B 2, 4, 5
  • C 1, 3, 5
  • D 2, 4
Answer: Option C
Q9
Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?
  • A While creating the object firstly the constructor of class B will be called followed by constructor of class A.
  • B While creating the object firstly the constructor of class A will be called followed by constructor of class B.
  • C The constructor of only class B will be called.
  • D The constructor of only class A will be called.
Answer: Option B
Q10
Which of the following is NOT a type of inheritance in C#?
  • A Single inheritance
  • B Multiple inheritance
  • C Hybrid inheritance
  • D Multilevel inheritance
Answer: Option C
Explanation: C# supports single, multiple through interfaces, multilevel, and hierarchical inheritance but not hybrid as a distinct type.
Questions and Answers for Competitive Exams Various Entrance Test