Basic C++ Interview Question and Answers

21. What are the advantages of inheritance?
 
    Inheritance has the following basic advantages.
  • 1. Reusability of code - Many applications are developed in an organization. Code developed for one application can be reused in another application if such functionality is required. This saves lot of development time.
  • Code sharing - The methods of the base class can be shared by the derived class.
  • Consistency of interface - The inherited attributes and methods provide a similar interface to the calling methods.
 
Your Name Your Email-ID
Your Answer
22. What is accessibility?
  An important feature in Inheritance is to known as to when a member of a base class can be used by the objects or the members of the derived class. This is called as accessibility.
 
Your Name Your Email-ID
Your Answer
23. What is copy constructor?
  A copy constructor is executed.
When an object is passed as a parameter to any of the member function.
When a member function returns an object.
When an object is passed by reference to constructor.
 
Your Name Your Email-ID
Your Answer
24. What are the functions of constructor?
  The constructor function initializes the class object.
The memory space is allocated to an object.
 
Your Name Your Email-ID
Your Answer
25. What are data members and member functions of a class?
  Data members are the data variables that represent the features or properties of a class.
Member functions are the functions that perform specific tasks in a class.
Member functions are called as methods, and data members are also called as attributes.
 
Your Name Your Email-ID
Your Answer
12345 Page 5 of 5