Home

C++ Programming 1000+ MCQ with answer for GATE

Thursday 9th of March 2023

Sharing is caring

1. Objects get destroyed in the reverse order as they are created.
A. True
B. False
C.
D.
Answer : A
2. 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
3. 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
4. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
5. 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
6. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
7. 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
8. We can make function inline by using the keyword 'inline'.
A. True
B. False
C.
D.
Answer : A
9. Class members are _______________ by default
A. Private
B. protected
C. public
D. None of the above are correct
Answer : A
10. 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
11. 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
12. In C++, the exception handler is invoked with a-
A. try block
B. throw exception
C. catch function
D. abort()
Answer : B
13. The ?: can be used to replace
A. if-else statement
B. wild cards
C. no meaning in C++
D. returns the value
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. The members of a class by default are private.
A. True
B. False
C.
D.
Answer : A
16. Protected members cannot be inherited.
A. True
B. False
C.
D.
Answer : B
17. 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
18. We cannot have the address of a constructor.
A. True
B. False
C.
D.
Answer : A
19. Reference to an object behaves like a constant pointer.
A. True
B. False
C.
D.
Answer : B
20. Data objects can be initialized when allocating memory using 'new'.
A. True
B. False
C.
D.
Answer : A
21. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A
22. 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
23. 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
24. _____________ operator must have one class object
A. +
B. new
C. all
D. None of these
Answer : B
25. 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
26. 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
27. 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
28. Constructor returns void type value.
A. True
B. False
C.
D.
Answer : B
29. The template function declaration specifies
A. template class
B. a generic class
C. exception
D. identifier
Answer : B
30. 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
31. The scope resolution operator is -
A. ::
B. ;
C. <<
D. ->
Answer : A
32. 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
33. this' pointer has to be used while accessing data members in a member function.
A. True
B. False
C.
D.
Answer : A
34. _______ argument(s) are passed in case of binary overloaded operators.
A. Two
B. One
C. No
D. None of the above
Answer : A
35. 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
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. A destructor can have arguments like constructor.
A. True
B. False
C.
D.
Answer : B
38. The value of 'this' pointer can be changed.
A. True
B. False
C.
D.
Answer : B
39. "[]" Operator is a unary operator.
A. True
B. False
C.
D.
Answer : A
40. 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
41. 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
42. Static data member occurs in only class scope.
A. True
B. False
C.
D.
Answer : B
43. In case of nested class, enclosing class can directly access the private data member of nested class.
A. True
B. False
C.
D.
Answer : A
44. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
45. If a friend function is declared inside a class it can access all data members of the class.
A. True
B. False
C.
D.
Answer : A
46. 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
47. 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
48. 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
49. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
50. 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

Sharing is caring