Home

1000+ C++ Programming Multiple Choice Question Answer [Solved]

Thursday 9th of March 2023

Sharing is caring

1. Member function cannot be called from within a constructor.
A. True
B. False
C.
D.
Answer : A
2. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
3. In C++, the exception handler is invoked with a-
A. try block
B. throw exception
C. catch function
D. abort()
Answer : B
4. Pick out the most appropriate statement
A. All variables must be declared before they are used
B. Variables in C++ need not be declared and the type can be assigned dynamically
C. Variables in C++ can be declared at the end of the program (before the main function terminates)
D. Variables can not be used explicitly in C++
Answer : A
5. By default, members cannot be inherited.
A. True
B. False
C.
D.
Answer : A
6. What is the output of the following program segment - for(i = 1, j = 0; i < 10; i++) j += i; cout <<i<<"
";

A. 10
B. 20
C. 55
D. there is an error in the program
Answer : A
7. Organizing data with methods that operate on the data and creating a new data type is called encapsulation.
A. True
B. False
C.
D.
Answer : A
8. By default, C++ uses the following method of passing arguments
A. Call-by-Reference
B. Call-by-Value
C. Call-by-Pointer
D. None of the above
Answer : B
9. "[]" Operator is a unary operator.
A. True
B. False
C.
D.
Answer : A
10. In C++, an identifier must be initialized using constant expression.
A. True
B. False
C.
D.
Answer : B
11. The ?: can be used to replace
A. if-else statement
B. wild cards
C. no meaning in C++
D. returns the value
Answer : A
12. One of the major disadvantage with late binding is
A. the source code should be made available at compile time
B. the program runs slower
C. dynamic variables can not be used in the program
D. static variables can not be used
Answer : B
13. Overloaded functions
A. Are a group of functions with the same name
B. All have the same number and types of arguments
C. Make life simpler for programmer
D. May fail unexpectedly due to stress
Answer : A
14. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
15. iostream is inheried from istream, ostream and ios class.
A. True
B. False
C.
D.
Answer : B
16. A variable defined within a block is visible
A. From the point of definition onwards in the program
B. From the point of definition onwards in the function
C. From the point of definition onwards in the block
D. Throughout the function
Answer : C
17. The signature of a function is
A. The return type
B. The number and type of arguments
C. The class of a function
D. None of the above
Answer : D
18. In a class, only the member function can access data, which is not accessible to outside. This feature is called:
A. Data security
B. Data hiding
C. Data manipulation
D. Data definition
Answer : B
19. Static member functions have file scope.
A. True
B. False
C.
D.
Answer : A
20. The library function exit() causes an exit from
A. The loop in which it occurs
B. The block in which it occurs
C. The function in which it occurs
D. The program in which it occurs
Answer : D
21. The break statement causes an exit
A. Only from the innermost loop
B. Only from the innermost switch
C. From all loops and switch
D. Only from the innermost loops or switch
Answer : A
22. Scope resolution operator has the highest precedence.
A. True
B. False
C.
D.
Answer : A
23. In C++, the keyword auto can be used for
A. Automatic assignment of data to object during instantiation
B. Automatic call of a function
C. To declare a local variable
D. It is not a keyword in C++
Answer : C
24. A class that contains at least one pure virtual function is called as
A. pure class
B. abstract class
C. base class
D. derived class
Answer : B
25. In a for loop with a multi-statement loop body, semicolons should appear following
A. The for statement itself
B. The closing brace in a multi-statement loop body
C. Each statement within the loop body.
D. The test expression
Answer : C
26. A direct access file is:
A. A file in which recoreds are arranged in a way they are inserted in a file
B. A file in which records are arranged in a particular order
C. Files which are stored on a direct access storage medium
D. None of the above
Answer : C
27. The members of a class can be made private by
A. declaring them private
B. by default they are private
C. by declaring them in the beginning of the program immediately after main()
D. they are always public
Answer : A
28. A copy constructor is used to copy an object member wise to another object of the same class.
A. True
B. False
C.
D.
Answer : A
29. When one object initializes another object the following function is invoked
A. copy constructor
B. new
C. instantiation
D. none of the above
Answer : A
30. Objects get destroyed in the reverse order as they are created.
A. True
B. False
C.
D.
Answer : A
31. One of the important features of an abstract class is
A. it need not have any object
B. it should be used only as a derived class
C. it need not have any members
D. none of the above
Answer : A
32. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A
33. Classes are useful because they
A. Are removed from memory when not in use
B. Permit data to be hidden from other classes
C. Bring together all aspects of an entity in one place
D. Can closely model objects in the real world
Answer : B
34. We cannot have the address of a constructor.
A. True
B. False
C.
D.
Answer : A
35. Reference to an object behaves like a constant pointer.
A. True
B. False
C.
D.
Answer : B
36. The exception is processed using
A. unexpected()
B. perform()
C. catch()
D. try()
Answer : C
37. It is possible to allow non member function access to private members of a class by declaring it as
A. public
B. friend
C. private
D. not possible
Answer : B
38. :: is known as
A. scope resolution operator
B. global operator
C. Both (a) & (b)
D. None of these
Answer : A
39. Protected data members can be accessed
A. Only from the base class itself
B. Both form the base class and from its derived classes
C. From the class which is friend of the base class
D. None of the above are correct
Answer : B
40. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
41. Public data members can be accessed
A. Only from the base class itself
B. Both form the base class and from its derived classes
C. From the class which is friend of the base class
D. None of the above are correct
Answer : B
42. The string table in C++ holds the
A. string constants in your program
B. program statements in string form
C. variables whose type is of string
D. none of the above
Answer : A
43. Static data member occurs in only class scope.
A. True
B. False
C.
D.
Answer : B
44. The getch() library function
A. Returns a character when any key is pressed
B. Returns a character when ENTER is pressed
C. Display a character on the screen when a key is pressed
D. Does not display a character on the screen
Answer : A
45. _______ argument(s) are passed in case of unary overloaded operators.
A. Two
B. One
C. No
D. None of the above
Answer : B
46. Inline function specifier reduces the overheads associated with a normal function call.
A. True
B. False
C.
D.
Answer : A
47. The member of a structure can be directly accessed by
A. ->
B. dot operator
C. ::
D. >>
Answer : B
48. A pure virtual function is a virtual function that has
A. no definition in its base class
B. a definition in its base class
C. a definition in at least one derived class
D. definition in base class and at least one derived class
Answer : A
49. A function that is called automatically when an object is destroyed is known as
A. instantiation
B. function prototype
C. constructor
D. destructor
Answer : D
50. Class is similar to a variable.
A. True
B. False
C.
D.
Answer : B

Sharing is caring