Home

1000+ C++ Programming MCQ for IIFT [Solved]

Thursday 9th of March 2023

Sharing is caring

1. 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
2. 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
3. _______ argument(s) are passed in case of binary overloaded operators.
A. Two
B. One
C. No
D. None of the above
Answer : A
4. 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
5. 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
6. Dynamic memory can be allocated by the following declaration
A. new
B. volatile
C. static
D. ==
Answer : A
7. A constructor cannot be explicitly called.
A. True
B. False
C.
D.
Answer : A
8. main() returns a value of type
A. real
B. char
C. int
D. null
Answer : C
9. The value of 'this' pointer can be changed.
A. True
B. False
C.
D.
Answer : B
10. 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
11. 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
12. 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
13. Class is similar to a variable.
A. True
B. False
C.
D.
Answer : B
14. 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
15. 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
16. A base class is inherited by
A. derived class
B. inline function
C. constructor
D. none of the above
Answer : A
17. 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
18. 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
19. The member of a structure can be accessed through a pointer by
A. ->
B. dot operator
C. ::
D. >>
Answer : A
20. 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
21. 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
22. 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
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. ios containes a pointer to streambuf.
A. True
B. False
C.
D.
Answer : A
25. new operator is used
A. To dynamically allocate storage
B. To statically allocate storage
C. To allocate storage for a new variable
D. None of the above are correct
Answer : C
26. 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
27. 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
28. A destructor can have a return type.
A. True
B. False
C.
D.
Answer : B
29. 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
30. 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
31. 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
32. 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
33. "[]" Operator is a unary operator.
A. True
B. False
C.
D.
Answer : A
34. 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
35. 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
36. 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
37. 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
38. Protected members cannot be inherited.
A. True
B. False
C.
D.
Answer : B
39. 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
40. 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
41. 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
42. _____________ operator must have one class object
A. +
B. new
C. all
D. None of these
Answer : B
43. We can make function inline by using the keyword 'inline'.
A. True
B. False
C.
D.
Answer : A
44. Private members of a structure can be accessed directly from the outside of the structure.
A. True
B. False
C.
D.
Answer : B
45. The new operator always returns a void pointer.
A. True
B. False
C.
D.
Answer : A
46. In C++, the stream base class is
A. iostream
B. iofstream
C. ios
D. stdio
Answer : C
47. 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
48. Element double Array[7] is which element of the array?
A. sixth
B. seventh
C. eighth
D. impossible to tell
Answer : C
49. A destructor can have arguments like constructor.
A. True
B. False
C.
D.
Answer : B
50. Inline function specifier reduces the overheads associated with a normal function call.
A. True
B. False
C.
D.
Answer : A

Sharing is caring