C# Questions & Answers – Fundamentals of Inheritance

This section of our 1000+ C# multiple choice questions focuses on fundamental of inheritance in C# Programming Language.

1. Which procedure among the following should be used to implement a ‘Has a’ or a ‘Kind of’ relationship between two entities?
a) Polymorphism
b) Inheritance
c) Templates
d) All of the mentioned
View Answer

Answer: b
Explanation: None.

2. The number of levels of inheritance are?
a) 5
b) 4
c) 3
d) 2
View Answer

Answer: b
Explanation: None.

3. What does the following C# code signify?

advertisement
advertisement
  1.  class a
  2.  {
  3.  
  4.  
  5.  
  6.  }
  7.  class b : a
  8.  {
  9.      variable declaration;
  10.      method declaration;
  11.  }

a) Declaration of a base class
b) Declaration of a subclass
c) Declaration of base class & subclass and how subclass inherits the base class
d) None of the mentioned
View Answer

Answer: c
Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. In an inheritance chain through which of the following, the base class and its components are accessible to the derived class?
a) Scope resolution operator(:)
b) Class visibility modifiers (public,private etc.)
c) Dot operator (.)
d) All of the mentioned
View Answer

Answer: b
Explanation: None.

5. Select the class visibility modifiers among the following:
a) Private, protected, public, internal
b) Private, protected, public, internal, protected internal
c) Private, protected, public
d) All of the mentioned
View Answer

Answer: b
Explanation: None.
advertisement

6. In Inheritance concept, which of the following members of base class are accessible to derived class members?
a) static
b) protected
c) private
d) shared
View Answer

Answer: b
Explanation: None.

7. Wrong statement about inheritance in C# .NET?
a) In inheritance chain, object construction begins from base class towards derived class
b) Inheritance cannot extend base class functionality
c) A derived class object contains all base class data
d) All of the mentioned
View Answer

Answer: b
Explanation:None.
advertisement

8. A class member declared protected becomes member of subclass of which type?
a) public member
b) private member
c) protected member
d) static member
View Answer

Answer: d
Explanation: A class member declared protected becomes private member of subclass.

9. Which of the following functionality is facilitated by inheritance mechanism?
a) Use the existing functionality of base class
b) Override the existing functionality of base class
c) Implements new functionality in derived class
d) All of the mentioned
View Answer

Answer: d
Explanation:None.

10. Which statements among following are correct?
a) We can derive a class from a base class even if source code of base class not available
b) Multiple inheritance is different from multiple levels of inheritance
c) It is legal to make objects of one class as members of another class
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

11. If base class consist of two private integers, one static integer and derived class consist of two static integers and one private integer. What would be the size of derived class object?
a) size of object depends on sizes of its non static data members
b) size of a derived class object is sum of sizes of non static data members of base class and derived class
c) size of object is calculated using sizeof() method
d) none of the mentioned
View Answer

Answer: a
Explanation: None.

12. Which is the correct way to create an object of the given class abc?
a) Declaring existing class as sealed
b) Declaring existing class as override
c) Declaring existing class as overloads
d) Declaring existing class as shadows
View Answer

Answer: a
Explanation: None.

13. Given class sample is inherited by class sample 1. Which are the correct statements about construction of object of class sample?
a) While creating the object firstly the constructor of class sample will be called followed by constructor of class sample 1
b) The constructor of only sample class will be called
c) While creating the object firstly constructor of class sample 1 will be called followed by constructor of class sample
d) The order of calling constructors depend on whether constructors in class sample and sample 1 are private or public
View Answer

Answer: c
Explanation: None.

14. Which form of inheritance is not supported directly by C# .NET?
a) Multiple inheritance
b) Multilevel inheritance
c) Single inheritance
d) Hierarchical inheritance
View Answer

Answer: a
Explanation: Supported in form of interfaces in secondary form.

15. If no access modifier for a class is specified, then class accessibility is defined as?
a) public
b) protected
c) private
d) internal
View Answer

Answer: c
Explanation: By default it is specified private in nature.

Sanfoundry Global Education & Learning Series – C# Programming Language.

To practice all areas of C# language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.