Home

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

Thursday 9th of March 2023

Sharing is caring

1. 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
2. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
3. The member of a structure can be accessed through a pointer by
A. ->
B. dot operator
C. ::
D. >>
Answer : A
4. A member function can always access the data
A. In the object of which it is a member
B. In the class of which it is a member
C. In the object of the class of which it is a member
D. In the public part of its class
Answer : B
5. Dynamic memory can be allocated by the following declaration
A. new
B. volatile
C. static
D. ==
Answer : A
6. Objects get destroyed in the reverse order as they are created.
A. True
B. False
C.
D.
Answer : A
7. 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
8. In C++, the exception handler is invoked with a-
A. try block
B. throw exception
C. catch function
D. abort()
Answer : B
9. 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
10. 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
11. Static data member can be declared as const too.
A. True
B. False
C.
D.
Answer : A
12. 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
13. A function that is called automatically when an object is created is known as
A. instantiation
B. function prototype
C. constructor
D. structure
Answer : C
14. 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
15. We can make function inline by using the keyword 'inline'.
A. True
B. False
C.
D.
Answer : A
16. 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
17. You can read input that consists of multiple lines of text using
A. The normal cout<< combination
B. The cin.get() function with one argument
C. The cin.get() function with two argument
D. The cin.get() function with three argument
Answer : C
18. _______ argument(s) are passed in case of unary overloaded operators.
A. Two
B. One
C. No
D. None of the above
Answer : B
19. Private members of a structure can be accessed directly from the outside of the structure.
A. True
B. False
C.
D.
Answer : B
20. Delete operator is used
A. To allocate storage
B. To deallocate storage
C. To delete variable name
D. None of the above are correct
Answer : B
21. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
22. new operator is used
A. To dynamically allocate storage
B. To statically allocate storage
C. To allocate storage for a new variable
D. None of the above are correct
Answer : C
23. The member of a structure can be directly accessed by
A. ->
B. dot operator
C. ::
D. >>
Answer : B
24. By default, members cannot be inherited.
A. True
B. False
C.
D.
Answer : A
25. If class A is friend of class B and if class B is friend of class C, which of the following is true?
A. Class C is friend of class A
B. Class A is friend of class C
C. Class A and Class C do not have any friend relationship
D. None of the above
Answer : B
26. 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
27. When accessing a structure member, the identifier to the left of the dot operator is the name of
A. Structure member
B. Structure tag
C. Structure variable
D. The keyword struct.
Answer : C
28. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
29. 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
30. 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
31. The value of 'this' pointer can be changed.
A. True
B. False
C.
D.
Answer : B
32. "[]" Operator is a unary operator.
A. True
B. False
C.
D.
Answer : A
33. 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
34. 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
35. Scope resolution operator has the highest precedence.
A. True
B. False
C.
D.
Answer : A
36. The declaration int **var1; shows that
A. var1 can not be accessed
B. var1 is a pointer to a pointer of type int
C. var1 is a protected data type of integer
D. this type declaration shows an error
Answer : B
37. Constructor returns void type value.
A. True
B. False
C.
D.
Answer : B
38. Friend function have access to the
A. private and protected members
B. public members only
C. private members only
D. None of the above are correct
Answer : B
39. 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
40. An object is an allocated space in memory.
A. True
B. False
C.
D.
Answer : A
41. Class members are _______________ by default
A. Private
B. protected
C. public
D. None of the above are correct
Answer : A
42. 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
43. When a language has the capacity to produce new data type, it is said to be
A. Reprehensible
B. Encapsulated
C. Overload
D. Extensible
Answer : D
44. _____________ operator must have one class object
A. +
B. new
C. all
D. None of these
Answer : B
45. 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
46. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
47. A destructor can have arguments like constructor.
A. True
B. False
C.
D.
Answer : B
48. Class is similar to a variable.
A. True
B. False
C.
D.
Answer : B
49. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
50. 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

Sharing is caring