Programming In C++ MCQs Set-7

PropellerAds
  1. 1. Function templates can accept
    • any type of parameters
    • only one parameter
    • only parameters of the basic type
    • only parameters of the derived type
  2. 2. How many constructors can a class have?
    • 0
    • 1
    • 2
    • any number
  3. 3. The new operator
    • returns a pointer to the variable
    • creates a variable called new
    • obtains memory for a new variable
    • tells how much memory is available
  4. 4. Consider the following statements: int x = 22,y=15; x = (x>y) ? (x+y) : (x-y); What will be the value of x after executing these statements?
    •  22
    • 37
    • 7
    • Error. Cannot be executed
  5. 5. An exception is caused by
    • a hardware problem
    • a problem in the operating system
    • a syntax error
    • a run-time error
  6. 6. A template class
    • is designed to be stored in different containers
    • works with different data types
    • generates objects which must be identical
    • generates classes with different numbers of member functions
  7. 7. Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?
    • class d : public b1, public b2
    • class d : class b1, class b2
    • class d : public b1, b2
    • class d : b1, b2
  8. 8. A library function exit() causes an exit from
    • the loop in which it occurs
    • the block in which it occurs
    •  the function in which it occurs
    • the program in which it occurs
  9. 9. RunTime polymorphism is achieved by ___________
    • friend function
    • virtual function
    • operator overloading
    • function overloading
  10. 10. Declaration of a pointer reserves memory space
    • for the object.
    • for the pointer.
    • both for the object and the pointer.
    • none of these.