Home

C++ Programming MCQ Solved Paper for UPSC IES

Thursday 9th of March 2023

Sharing is caring

1. "[]" Operator is a unary operator.
A. True
B. False
C.
D.
Answer : A
2. 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
3. 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
4. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
5. cc ___________ option is used only to create object file
A. -a
B. -o
C. -c
D. none of these
Answer : B
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. By default, members cannot be inherited.
A. True
B. False
C.
D.
Answer : A
8. Which of the following relationship is known as inheritancerelationship?
A. ‘has-a’ relationship
B. ‘is-a’ relationship
C. association relationship
D. none of the above
Answer : A
9. Sharing of common information are achieved by the concept of
A. Virtual copying
B. Inheritance
C. Encapsulation
D. None of these
Answer : B
10. Constructor returns void type value.
A. True
B. False
C.
D.
Answer : B
11. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
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. 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
14. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
15. We cannot have the address of a constructor.
A. True
B. False
C.
D.
Answer : A
16. 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
17. 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
18. 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
19. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
20. Which of the following is not a component of file system
A. Access method
B. Auxiliary storage management
C. Free integrity mechanism
D. None of the above
Answer : C
21. 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
22. A destructor can have arguments like constructor.
A. True
B. False
C.
D.
Answer : B
23. Objects get destroyed in the reverse order as they are created.
A. True
B. False
C.
D.
Answer : A
24. Private data members can be accessed
A. Only from the base class itself
B. Both from the base class and form its derived classes
C. From the class which is a friend of the base class
D. None of the above is correct
Answer : A
25. _______ argument(s) are passed in case of unary overloaded operators.
A. Two
B. One
C. No
D. None of the above
Answer : B
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. 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
28. A constructor cannot be explicitly called.
A. True
B. False
C.
D.
Answer : A
29. _____________ operator must have one class object
A. +
B. new
C. all
D. None of these
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 member of a structure can be accessed through a pointer by
A. ->
B. dot operator
C. ::
D. >>
Answer : A
32. The following syntax is valid. void inline gram_ panchayat :: show_gram_ panchayat_info().
A. True
B. False
C.
D.
Answer : B
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. 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
35. 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
36. 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
37. The scope resolution operator is -
A. ::
B. ;
C. <<
D. ->
Answer : A
38. 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
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. 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
41. The member of a structure can be directly accessed by
A. ->
B. dot operator
C. ::
D. >>
Answer : B
42. The value of 'this' pointer can be changed.
A. True
B. False
C.
D.
Answer : B
43. Member function cannot be called from within a constructor.
A. True
B. False
C.
D.
Answer : A
44. We can make function inline by using the keyword 'inline'.
A. True
B. False
C.
D.
Answer : A
45. Reference to an object behaves like a constant pointer.
A. True
B. False
C.
D.
Answer : B
46. The ?: can be used to replace
A. if-else statement
B. wild cards
C. no meaning in C++
D. returns the value
Answer : A
47. Which of the following is true about const member functions?
A. const members can be invoked on both const as well as nonconst objects
B. const members can be invoked only on const objects and not on nonconst objects
C. nonconst members can be invoked on const objects as well as nonconst objects
D. none of the above
Answer : B
48. 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
49. 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
50. 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

Sharing is caring