CPP MCQ
CPP MCQ
CPP MCQ
Made By Pragnesh
1. If the class name is X, what is the type of its “this” pointer (in a
nonstatic, non-const member function)?
a. const X* const
b. X* const
c. X*
d. X&
2. Which classes allow primitive types to be accessed as objects?
a. Storage
b. Virtual
c. Friend
d. Wrapper
3. When is std::bad_alloc exception thrown?
a. When new operator cannot allocate memory
b. When alloc function fails
c. When type requested for new operation is considered bad,
thisexception is thrown
d. When delete operator cannot delete teh allocated (corrupted)
object
4. Which one of the following is not a fundamental data type in C++
a. float
b. string
c. int
d. wchar_t
5. Which of the following is a valid destructor of the class name
"Country"
a. int ~Country()
b. void Country()
c. int ~Country(Country obj)
d. void ~Country()
6. Which of the following correctly describes C++ language?
a. Statically typed language
b. Dynamically typed language
c. Both Statically and dynamically typed language
d. Type-less language
7. Which of the following keyword supports dynamic method
resolution?
a. abstract
b. Virtual
c. Dynamic
d. Typeid
8. Which of the following is the most preferred way of throwing
and handling exceptions?
a. Throw by value and catch by reference.
b. Throw by reference and catch by reference.
c. Throw by value and catch by value
d. Throw the pointer value and provide catch for teh pointer type.
9. Which of the following is not true about preprocessor directives
a. They begin with a hash symbol
b. They are processed by a preprocessor
c. They form an integral part of the code
d. They have to end with a semi colon
10. What's wrong? while( (i < 10) && (i > 24))
a. the logical operator && cannot be used in a test condition
b. the while loop is an exit-condition loop
c. the test condition is always false
d. the test condition is always true
11. A continue statement causes execution to skip to
a. the return 0; statement
b. the first statement after the loop
c. the statement following the continue statement
d. the next iteration of the loop
12. What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);
a. the question mark should be an equal sign
b. the first semicolon should be a colon
c. there are too many variables in the statement
d. the conditional operator is only used with apstrings
Answer
1 - d 2 - b 3 - d 4 - a 5 - b 6 - d 7 - a 8 - b 9 - a 10 - d
11 - c 12 - d 13 - b 14 - d 15 - c 16 - a 17 - a 18 - b 19 - c 20 - c
21 - b 22 - a 23 - b 24 - c 25 - c 26 - d 27 - b 28 - b 29 - a 30 - c
31 - d 32 - c 33 - b 34 - a 35 - d 36 - c 37 - c 38 - a 39 - c 40 - a
41 - d 42 - d 43 - b 44 - d 45 - a 46 - a 47 - a 48 - c 49 - d 50 - d
51 - a 52 - b 53 - d 54 - a 55 - b 56 - c 57 - C 58 - D 59 - a 60 - a
61 - c 62 - c 63 - b 64 - c 65 - b 66 - b 67 - a 68 - d 69 - b 70 - d
71 - a 72 - a 73 - c 74 - c 75 - b 76 - c 77 - a 78 - c 79 - a 80 - c
81 - d 82 - d 83 - b 84 - d 85 - a 86 - b 87 - a 88 - b 89 - d 90 - a
91 - b 92 - d 93 - d 94 - a 95 - b 96 - b 97 - b 98 - b 99 - c 100 - b