C++ programming language

11. Declaration of a pointer reserves memory space

  1. for the object.
  2. for the pointer.
  3. both for the object and the pointer.
  4. none of these.

Correct answer: (B)
for the pointer.

12. Exception handling is targeted at

  1. Run-time error
  2. Compile time error
  3. Logical error
  4. All of the above.

Correct answer: (A)
Run-time error

13. for (; ;)

  1. means the test which is done using some expression is always true
  2. is not valid
  3. will loop forever
  4. should be written as for( )

Correct answer: (C)
will loop forever

14. Given a class named Book, which of the following is not a valid constructor?

  1. Book ( ) { }
  2. Book ( Book b) { }
  3. Book ( Book & b) { }
  4. Book (char* author, char* title) { }

Correct answer: (B)
Book ( Book b) { }

15. Identify the operator that is NOT used with pointers

  1. ->
  2. &
  3. *
  4. >>

Correct answer: (D)
>>

16. If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access

  1. protected and public data only in C and B.
  2. protected and public data only in C.
  3. private data in A and B.
  4. protected data in A and B.

Correct answer: (D)
protected data in A and B.

17. If an array is declared as int a[4] = {3, 0, 1, 2}, then values assigned to a[0] & a[4] will be _________

  1. 3, 2
  2. 0, 2
  3. 3, 0
  4. 0, 4

Correct answer: (C)
3, 0

18. If the variable count exceeds 100, a single statement that prints 'Too many' is

  1. if (count<100) cout << 'Too many';
  2. if (count>100) cout >> 'Too many';
  3. if (count>100) cout << 'Too many';
  4. None of these.

Correct answer: (C)
if (count>100) cout << 'Too many';

19. If we create a file by ,ifstream', then the default mode of the file is _________

  1. ios :: out
  2. ios :: in
  3. ios :: app
  4. ios :: binary

Correct answer: (B)
ios :: in

20. If x = 5, y = 2 then x ^ y equals_________. (where ^ is a bitwise XOR operator)

  1. 111
  2. 10000010
  3. 10100000
  4. 11001000

Correct answer: (A)
111

Page 2 of 5