Home

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

Thursday 9th of March 2023

Sharing is caring

1. 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
2. Class members are _______________ by default
A. Private
B. protected
C. public
D. None of the above are correct
Answer : A
3. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
4. The value of 'this' pointer can be changed.
A. True
B. False
C.
D.
Answer : B
5. Static data member can be declared as const too.
A. True
B. False
C.
D.
Answer : A
6. Private members of a structure can be accessed directly from the outside of the structure.
A. True
B. False
C.
D.
Answer : B
7. By default, members cannot be inherited.
A. True
B. False
C.
D.
Answer : A
8. 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
9. Data objects can be initialized when allocating memory using 'new'.
A. True
B. False
C.
D.
Answer : A
10. 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
11. Sharing of common information are achieved by the concept of
A. Virtual copying
B. Inheritance
C. Encapsulation
D. None of these
Answer : B
12. 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
13. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
14. 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
15. When you overload an arithmetic assignment operator, the result
A. Goes in the object to the right of the operator
B. Goes in the object to the left of the operator
C. Goes in the object of which the operator is a member
D. Must be returned
Answer : B
16. The member of a structure can be accessed through a pointer by
A. ->
B. dot operator
C. ::
D. >>
Answer : A
17. :: is known as
A. scope resolution operator
B. global operator
C. Both (a) & (b)
D. None of these
Answer : A
18. cc ___________ option is used only to create object file
A. -a
B. -o
C. -c
D. none of these
Answer : B
19. The following syntax is valid. void inline gram_ panchayat :: show_gram_ panchayat_info().
A. True
B. False
C.
D.
Answer : B
20. 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
21. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
22. 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
23. iostream is inheried from istream, ostream and ios class.
A. True
B. False
C.
D.
Answer : B
24. 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
25. Dynamic memory can be allocated by the following declaration
A. new
B. volatile
C. static
D. ==
Answer : A
26. 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
27. The scope resolution operator is -
A. ::
B. ;
C. <<
D. ->
Answer : A
28. A normal C++ operator that acts in a special way on newly defined data types is said to be
A. Glorified
B. Encapsulated
C. Classified
D. Overloaded
Answer : D
29. _____________ operator must have one class object
A. +
B. new
C. all
D. None of these
Answer : B
30. Protected members cannot be inherited.
A. True
B. False
C.
D.
Answer : B
31. 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
32. 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
33. 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
34. A destructor can have arguments like constructor.
A. True
B. False
C.
D.
Answer : B
35. In C++, an identifier must be initialized using constant expression.
A. True
B. False
C.
D.
Answer : B
36. Pick out the most appropriate statement from the following
A. references are pointers
B. array of references can be created
C. you can not reference a reference variable
D. all of the above
Answer : C
37. 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
38. The characteristic that data can be manipulated only through member functions that are part of the class is called
A. Encapsulation
B. Data dependency
C. Inheritance
D. Instantiation
Answer : A
39. In C++, the exception handler is invoked with a-
A. try block
B. throw exception
C. catch function
D. abort()
Answer : B
40. Which of the following can legitimately be passed to a function?
A. A constant
B. A variable
C. A structure
D. A header file
Answer : B
41. The binding that binds a function call at run time is called
A. early binding
B. run time binding
C. late binding
D. linking
Answer : C
42. 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
43. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A
44. Inline function specifier reduces the overheads associated with a normal function call.
A. True
B. False
C.
D.
Answer : A
45. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
46. Objects get destroyed in the reverse order as they are created.
A. True
B. False
C.
D.
Answer : A
47. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
48. 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
49. The members of a class by default are private.
A. True
B. False
C.
D.
Answer : A
50. 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

Sharing is caring