Select chapter



constructors (2.papers)
inheritance (1.papers)
overriding (1.papers)
basics (4.papers)
pointers (2.papers)
Hide

Sponsored Links


  

c++ inheritance interview questions and answers

1
class Bike
{
    Engine objEng;
};
class Engine
{
    float CC;
};
  1. kind of relationship
  2. has a relationship
  3. is a relationship
  4. none
Show Answer
Share Facebook gmail Twitter
2
Which allows you to create a derived class that inherits properties from more than one base class?
  1. Multilevel inheritance
  2. Multiple inheritance
  3. Hybrid inheritance
  4. Hierarchical inheritance
Show Answer
Share Facebook gmail Twitter
3
What is Inheritance?
  1. Acquiring the properties and behaviors from base class to derived class is called as inheritance.
  2. Having same function in base class and derived class is called as inheritance.
  3. Having multiple functions with same name in same class is called as inheritance
  4. none
Show Answer
Share Facebook gmail Twitter
4
What is the use of Inheritance?
  1. Code reusability
  2. Reduced project development time
  3. both 1 & 2
  4. none
Show Answer
Share Facebook gmail Twitter
5
Inheritance is ?
  1. IS-A relationship
  2. Has-A relationship
  3. both Is-A and Has-A
  4. none
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Which of the below are not an example of  polymorphism concept in c++?
  1. function overloading
  2. function over riding
  3. operator overloading
  4. none
Show Answer
Share Facebook gmail Twitter
9
Major purpose in c++ to create
templates is_____
  1. inheritance
  2. generic programming
  3. polymorphism
  4. none
Show Answer
Share Facebook gmail Twitter
10
What is HAS-A relationship?
  1. inheritance
  2. interface
  3. A class having an object of another class as its member, then it is Has-A relationship.
  4. there is nothing like HAS-A relationship in c++
Show Answer
Share Facebook gmail Twitter
11
What is multiple inheritance?
  1. a derived class deriving directly from more than one base class.
  2. a derived class deriving from other derived class which is derived from base class.
  3. a class having more than one derived class
  4. having only one base class and one derived class.
Show Answer
Share Facebook gmail Twitter
12
What is the advantage of multiple inheritance?
  1. there is no advantage as such.
  2. you can derive properties and behaviors from more than one class directly.
  3. none
Show Answer
Share Facebook gmail Twitter
13
What is the disadvantage of multiple inheritance?
  1. it is good to have multiple inheritance.
  2. compiler will get confused if you inherit more than one base class. This is the disadvantage.
  3. Problem comes if both the base classes have same function with different  signature. Ambiguity arises in derived class.
  4. Problem comes if both the base classes have same function with same signature. Ambiguity arises in derived class.
Show Answer
Share Facebook gmail Twitter
14
What will happen if I have base class with function fun(), and this base class is derived into classes der1, and der2. Now assume that class der3 inherits both der1, and der2. Is there any problem in this scenario?
  1. no error, its proper. C++ allows multiple inheritance.
  2. we have to use virtual keyword for function fun() in base class. Else it gives compile time error.
  3. It will give compile time error, only if we try to access fun() by using Der3 object. This is because of ambiguity.
  4. none
Show Answer
Share Facebook gmail Twitter
15
Does c++ support multiple inheritance of classes?
  1. Yes, it does support.
  2. No. Multiple inheritance of classes is not allowed but multiple inheritance of interfaces are allowed.
  3. there is no concept of multiple inheritance in c++.
  4. can't say
Show Answer
Share Facebook gmail Twitter
16
This pointer returns
_____
  1. NULL
  2. Object that is accessing 
    the function
  3. Address of current variable
  4. none
Show Answer
Share Facebook gmail Twitter
17
What will happen if I have base class with function fun(), and this base class is derived into classes der1, and der2. Now assume that class der3 inherits both der1, and der2.  Now I have created to Der3 d; and trying to access d.fun(). It throws compile time error ambiguity. How to resolve this issue?
  1. you can resolve this by using scope resolution operator with any of your base classes. For eg,   d.Der1::fun();
  2. you can resolve this issue by making the function fun() of base class as virtual.
  3. either you can use option 1 or option 2.
  4. you have to use both the options 1&2 to resolve this issue.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :