Home

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

Thursday 9th of March 2023

Sharing is caring

1. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A
2. 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
3. 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
4. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
5. 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
6. 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
7. Sharing of common information are achieved by the concept of
A. Virtual copying
B. Inheritance
C. Encapsulation
D. None of these
Answer : B
8. iostream is inheried from istream, ostream and ios class.
A. True
B. False
C.
D.
Answer : B
9. 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
10. 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
11. 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
12. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
13. The exception is processed using
A. unexpected()
B. perform()
C. catch()
D. try()
Answer : C
14. Static member functions have file scope.
A. True
B. False
C.
D.
Answer : A
15. 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
16. Operator overloading is
A. Making C++ operators work with objects
B. Making C++ operators more then they can handle
C. Giving new meaning to existing c++ operators
D. Making new C++ operators
Answer : C
17. Static data member can be declared as const too.
A. True
B. False
C.
D.
Answer : A
18. 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
19. 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
20. 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
21. 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
22. 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
23. What is the value of Friday in the following - enum days { Monday, Tuesday, Wednesday = -1, Thursday, Friday, Saturday = 6, Sunday}
A. 1
B. 5
C. 0
D. -3
Answer : A
24. 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
25. The && and || operators
A. Compare two numeric values
B. Combine two numeric values
C. Compare two Boolean values
D. Combine two Boolean values
Answer : C
26. 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
27. Private members of a structure can be accessed directly from the outside of the structure.
A. True
B. False
C.
D.
Answer : B
28. 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
29. 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
30. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
31. 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
32. Data objects can be initialized when allocating memory using 'new'.
A. True
B. False
C.
D.
Answer : A
33. 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
34. 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
35. Member function cannot be called from within a constructor.
A. True
B. False
C.
D.
Answer : A
36. Static data member occurs in only class scope.
A. True
B. False
C.
D.
Answer : B
37. 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
38. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
39. By default, members cannot be inherited.
A. True
B. False
C.
D.
Answer : A
40. 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
41. Scope resolution operator has the highest precedence.
A. True
B. False
C.
D.
Answer : A
42. Protected members cannot be inherited.
A. True
B. False
C.
D.
Answer : B
43. :: is known as
A. scope resolution operator
B. global operator
C. Both (a) & (b)
D. None of these
Answer : A
44. 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
45. 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
46. Class is similar to a variable.
A. True
B. False
C.
D.
Answer : B
47. The scope resolution operator is -
A. ::
B. ;
C. <<
D. ->
Answer : A
48. By using protected, one can create class members that are private to their class but
A. that can not be inherited and accessed by a derived class
B. that can still be inherited and accessed by a derived class
C. that can be public
D. none of the above
Answer : B
49. 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
50. Objects get destroyed in the reverse order as they are created.
A. True
B. False
C.
D.
Answer : A

Sharing is caring