Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

If a base class contains a member function , and a derived class does not contain a function with this name, an object of the derived class cannot access .

Answer» It depends upon how the function func() has been defined in the base class. If the function func() is defined public in base class then an object of the derived class can access the function func().
2.

If a base class and a derived class each include a member function with the same name, the member function of the derived class will be called by an object of the derived class

Answer» This is because the member functions are always searched in the derived class and then in the base class.
3.

A class can be derived from a class , which is derived from a class , which is derived from a class .

Answer» This is known as multiple levels of inheritance.
4.

An object of a derived class cannot access private members of base class.

Answer» The private members of the base class are never accessible outside the class.
5.

The way a derived class member function can access base class public members, the base class member functions can access public member functions of derived class.

Answer» Base class cannot access derived class members since it does not have any knowledge of the derived class.
6.

We can derive a class from a base class even if the base class's source code is not available.

Answer» We can derive from a base class even if it is present in an assembly.
7.

Multiple inheritance is different from multiple levels of inheritance.

Answer» Multiple inheritance means deriving a class from more than one classes. On the other hand, multiple levels of inheritance means a class has been derived from a base class and the base class itself has been derived from another base class. Multiple inheritance is not permitted in C#.NET.
8.

How can you prevent inheritance from a class in C#.NET ?

Answer» C#.NET allows sealed attribute to be used as a part of class statement. Classes declared with sealed keyword cannot be used as based class for other classes. Most important reason to do this world be to prevent behavior of a class to be changed in any way.