C++ programming language

41. Usually a pure virtual function

  1. has complete function body.
  2. will never be called.
  3. will be called only to delete an object.
  4. is defined only in derived class.

Correct answer: (D)
is defined only in derived class.

42. What is the output of the following code char symbol[3]={,a',b',,c'}; for (int index=0; index<3; index++) cout <#60;< symbol [index];

  1. a b c
  2. 'abc'
  3. abc
  4. abc'

Correct answer: (C)
abc

43. Which of the following cannot be legitimately passed to a function

  1. A constant.
  2. A variable.
  3. A structure.
  4. A header file.

Correct answer: (D)
A header file.

44. Which of the following is false for cin?

  1. It represents standard input.
  2. It is an object of istream class.
  3. It is a class of which stream is an object.
  4. Using cin the data can be read from user's terminal.

Correct answer: (C)
It is a class of which stream is an object.

45. Which of the following statements is NOT valid about operator overloading?

  1. Only existing operators can be overloaded.
  2. Overloaded operator must have at least one operand of its class type.
  3. The overloaded operators follow the syntax rules of the original operator.
  4. none of the above.

Correct answer: (D)
none of the above.

46. Which of the statements is true in a protected derivation of a derived class from a base class?

  1. Private members of the base class become protected members of the derived class
  2. Protected members of the base class become public members of the derived class
  3. Public members of the base class become protected members of the derived class
  4. Protected derivation does not affect private and protected members of the derived class.

Correct answer: (C)
Public members of the base class become protected members of the derived class

47. Which statement gets affected when i++ is changed to ++i?

  1. i = 20; i++;
  2. for (i = 0; i<20; i++) { }
  3. a = i++;
  4. while (i++ = 20) cout <<i;

Correct answer: (A)
i = 20; i++;

48. Within a switch statement

  1. Continue can be used but Break cannot be used
  2. Continue cannot be used but Break can be used
  3. Both Continue and Break can be used
  4. Neither Continue nor Break can be used

Correct answer: (B)
Continue cannot be used but Break can be used

49. You can read input that consists of multiple lines of text using

  1. the normal cout << combination.
  2. the cin.get( ) function with one argument.
  3. the cin.get( ) function with two arguments.
  4. the cin.get( ) function with three arguments.

Correct answer: (C)
the cin.get( ) function with two arguments.

Page 5 of 5