C++ Interview Question and Answers

116. What is an adaptor class or Wrapper class?
  A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non-objectoriented implementation.
 
Your Name Your Email-ID
Your Answer
117. What is a Null object?
  It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
 
Your Name Your Email-ID
Your Answer
118. What is class invariant?
 
  • A class invariant is a condition that defines all valid states for an object.
  • It is a logical condition to ensure the correct working of a class.
  • Class invariants must hold when an object is created, and they must be preserved under all operations of the class.
  • In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.
 
Your Name Your Email-ID
Your Answer
119. What is the difference between the message and method?
  Message : Objects communicate by sending messages to each other.A message is sent to invoke a method.
Method : Provides response to a message and it is an implementation of an operation.
 
Your Name Your Email-ID
Your Answer
120. Is it possible to use a new for the reallocation of pointers?
  The reallocation of pointers cannot be done by using new. It can be done by using the realloc() operator.
 
Your Name Your Email-ID
Your Answer