C++ programming language

21. If you wanted to sort many large objects or structures, it would be most efficient to

  1. place them in an array & sort the array.
  2. place pointers to them in an array & sort the array.
  3. place them in a linked list and sort the linked list.
  4. place references to them in an array and sort the array.

Correct answer: (C)
place them in a linked list and sort the linked list.

22. In C++, dynamic memory allocation is accomplished with the operator _________

  1. new
  2. this
  3. malloc( )
  4. delete

Correct answer: (A)
new

23. In multiple inheritance

  1. the base classes must have only default constructors
  2. cannot have virtual functions
  3. can include virtual classes
  4. None of the above.

Correct answer: (C)
can include virtual classes

24. In which case is it mandatory to provide a destructor in a class?

  1. Almost in every class
  2. Class for which two or more than two objects will be created
  3. Class for which copy constructor is defined
  4. Class whose objects will be created dynamically

Correct answer: (D)
Class whose objects will be created dynamically

25. It is possible to declare as a friend

  1. a member function
  2. a global function
  3. a class
  4. all of the above

Correct answer: (D)
all of the above

26. Mechanism of deriving a class from another derived class is known as _________

  1. Polymorphism
  2. Single Inheritance
  3. Multilevel Inheritance
  4. Message Passing

Correct answer: (C)
Multilevel Inheritance

27. Overloading the function operator

  1. requires a class with an overloaded operator.
  2. requires a class with an overloaded [ ] operator.
  3. allows you to create objects that act syntactically like functions.
  4. usually make use of a constructor that takes arguments.

Correct answer: (A)
requires a class with an overloaded operator.

28. Pure virtual functions

  1. have to be redefined in the inherited class.
  2. cannot have public access specification.
  3. are mandatory for a virtual class.
  4. None of the above.

Correct answer: (A)
have to be redefined in the inherited class.

29. RunTime Polymorphism is achieved by _________

  1. friend function
  2. virtual function
  3. operator overloading
  4. function overloading

Correct answer: (B)
virtual function

30. The address of a variable temp of type float is

  1. *temp
  2. &temp
  3. float & temp
  4. float temp &

Correct answer: (B)
&temp

Page 3 of 5