Home

NMAT - C++ Programming 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. iostream is inheried from istream, ostream and ios class.
A. True
B. False
C.
D.
Answer : B
2. Protected members cannot be inherited.
A. True
B. False
C.
D.
Answer : B
3. 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
4. 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
5. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
6. 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
7. Inline function specifier reduces the overheads associated with a normal function call.
A. True
B. False
C.
D.
Answer : A
8. In C++, identifiers have to be declared at the beginning of the blocks.
A. True
B. False
C.
D.
Answer : A
9. cc ___________ option is used only to create object file
A. -a
B. -o
C. -c
D. none of these
Answer : B
10. By default, C++ uses the following method of passing arguments
A. Call-by-Reference
B. Call-by-Value
C. Call-by-Pointer
D. None of the above
Answer : B
11. An object is an allocated space in memory.
A. True
B. False
C.
D.
Answer : A
12. :: is known as
A. scope resolution operator
B. global operator
C. Both (a) & (b)
D. None of these
Answer : A
13. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
14. Class members are _______________ by default
A. Private
B. protected
C. public
D. None of the above are correct
Answer : A
15. 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
16. Data objects can be initialized when allocating memory using 'new'.
A. True
B. False
C.
D.
Answer : A
17. 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
18. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
19. 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
20. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A
21. The scope resolution operator is -
A. ::
B. ;
C. <<
D. ->
Answer : A
22. 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
23. The ?: can be used to replace
A. if-else statement
B. wild cards
C. no meaning in C++
D. returns the value
Answer : A
24. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
25. 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
26. 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
27. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
28. 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
29. 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
30. A constructor cannot be explicitly called.
A. True
B. False
C.
D.
Answer : A
31. 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
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. 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
34. 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
35. The member of a structure can be directly accessed by
A. ->
B. dot operator
C. ::
D. >>
Answer : B
36. 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
37. 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
38. Member function cannot be called from within a constructor.
A. True
B. False
C.
D.
Answer : A
39. 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
40. The members of a class by default are private.
A. True
B. False
C.
D.
Answer : A
41. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
42. 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
43. 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
44. 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
45. Class is similar to a variable.
A. True
B. False
C.
D.
Answer : B
46. 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
47. 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
48. 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
49. Scope resolution operator has the highest precedence.
A. True
B. False
C.
D.
Answer : A
50. 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

Sharing is caring