Home

C++ Programming MCQ Solved Paper for UPSC CDS

Thursday 9th of March 2023

Sharing is caring

1. 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
2. The string table in C++ holds the
A. string constants in your program
B. program statements in string form
C. variables whose type is of string
D. none of the above
Answer : A
3. 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
4. The following syntax is valid. void inline gram_ panchayat :: show_gram_ panchayat_info().
A. True
B. False
C.
D.
Answer : B
5. 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
6. 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
7. 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
8. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
9. 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
10. The scope resolution operator is -
A. ::
B. ;
C. <<
D. ->
Answer : A
11. We cannot have the address of a constructor.
A. True
B. False
C.
D.
Answer : A
12. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
13. Inline functions_____________ call overload.
A. Increase
B. Reduce
C. None of the above are correct
D.
Answer : B
14. 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
15. The member of a structure can be directly accessed by
A. ->
B. dot operator
C. ::
D. >>
Answer : B
16. 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
17. 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
18. Member function cannot be called from within a constructor.
A. True
B. False
C.
D.
Answer : A
19. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
20. Sharing of common information are achieved by the concept of
A. Virtual copying
B. Inheritance
C. Encapsulation
D. None of these
Answer : B
21. iostream is inheried from istream, ostream and ios class.
A. True
B. False
C.
D.
Answer : B
22. The exception is processed using
A. unexpected()
B. perform()
C. catch()
D. try()
Answer : C
23. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
24. Dynamic memory can be allocated by the following declaration
A. new
B. volatile
C. static
D. ==
Answer : A
25. 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
26. 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
27. 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
28. Class members are _______________ by default
A. Private
B. protected
C. public
D. None of the above are correct
Answer : A
29. _______ argument(s) are passed in case of unary overloaded operators.
A. Two
B. One
C. No
D. None of the above
Answer : B
30. 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
31. 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
32. Reference to an object behaves like a constant pointer.
A. True
B. False
C.
D.
Answer : B
33. :: is known as
A. scope resolution operator
B. global operator
C. Both (a) & (b)
D. None of these
Answer : A
34. 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
35. The ?: can be used to replace
A. if-else statement
B. wild cards
C. no meaning in C++
D. returns the value
Answer : A
36. 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
37. Static data member can be declared as const too.
A. True
B. False
C.
D.
Answer : A
38. 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
39. this' is an implicit pointer.
A. True
B. False
C.
D.
Answer : A
40. A destructor can have arguments like constructor.
A. True
B. False
C.
D.
Answer : B
41. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
42. cc ___________ option is used only to create object file
A. -a
B. -o
C. -c
D. none of these
Answer : B
43. _____________ operator must have one class object
A. +
B. new
C. all
D. None of these
Answer : B
44. 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
45. Which of the following are good reasons to use an object oriented language?
A. You can define your data types
B. Program statements are simpler than in procedural languages.
C. An OO program can be taught to correct its own errors.
D. It's easier to conceptualize an OO program.
Answer : A
46. In C++, the exception handler is invoked with a-
A. try block
B. throw exception
C. catch function
D. abort()
Answer : B
47. Constructor returns void type value.
A. True
B. False
C.
D.
Answer : B
48. An object is an allocated space in memory.
A. True
B. False
C.
D.
Answer : A
49. In C++, an identifier must be initialized using constant expression.
A. True
B. False
C.
D.
Answer : B
50. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A

Sharing is caring