Programming In C++ MCQs Set-5

1. A virtual class is the same as
  • an abstract class
  • a class with a virtual function
  • a base class
  • none of the above.
2. Identify the operator that is NOT used with pointers
  • ->
  • &
  • *
  • >>
3. Consider the following statements char *ptr; ptr = “hello”; cout << *ptr; What will be printed?
  • first letter
  • entire string
  • it is a syntax error
  • last letter
4. In which case is it mandatory to provide a destructor in a class?
  • Almost in every class
  • Class for which two or more than two objects will be created
  • Class for which copy constructor is defined
  • Class whose objects will be created dynamically
5. The members of a class, by default, are
  • public
  • protected
  • private
  • mandatory to specify
6. Given a class named Book, which of the following is not a valid constructor?
  • Book ( ) { }
  • Book ( Book b) { }
  • Book ( Book &b) { }
  • Book (char* author, char* title) { }
7. Which of the statements is true in a protected derivation of a derived class from a base class?
  • Private members of the base class become protected members of the derived class
  • Protected members of the base class become public members of the derived class
  • Public members of the base class become protected members of the derived class
  • Protected derivation does not affect private and protected members of the 
8. Which of the following statements is NOT valid about operator overloading?
  • Only existing operators can be overloaded.
  • Overloaded operator must have at least one operand of its class type.
  • The overloaded operators follow the syntax rules of the original operator.
  • none of the above.
9. Exception handling is targeted at
  • Run-time error
  • Compile time error
  • Logical error
  • All of the above.
10. A pointer to the base class can hold address of
  • only base class object
  • only derived class object
  • base class object as well as derived class object
  • None of the above