C Sharp Inheritance Questions and Answers
Practice ModeShowing 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.
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 ***]
}
}
Answer: Option B
Q3
Which of the following should be used to implement a 'Has a' relationship between two entities?
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
Answer: Option B
Q5
Which of the following are reuse mechanisms available in C#.NET?
Inheritance
Encapsulation
Templates
Containership
Polymorphism
Answer: Option A
Q6
Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?
Answer: Option
Q7
Which of the following is the correct way to create an object of the class Sample?
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.
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?
Answer: Option B
Q10
Which of the following is NOT a type of inheritance in C#?
Answer: Option C
Explanation: C# supports single, multiple through interfaces, multilevel, and hierarchical inheritance but not hybrid as a distinct type.