Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q321: In the statement cout << y++;, what value is printed?
- A: The incremented value of y
- B: The original value of y
- C: An error occurs
- D: Garbage value
View Answer
B
Q322: What is the output of the following code? int y = 2; ++y; cout << y;
- A: 2
- B: 3
- C: 4
- D: 1
View Answer
B
Q323: In the modified String class, how is the post-increment operator (++) implemented?
- A: Using a non-member function
- B: Using a friend function
- C: Using a member function
- D: Using a static function
View Answer
C
Q324: The post-increment operator (++) in a class returns:
- A: The current object
- B: A temporary object
- C: The original object
- D: A null object
View Answer
B
Q325: Which of the following is required to convert a user-defined type to another type?
- A: A constructor with a single parameter
- B: A destructor
- C: An operator function
- D: A copy constructor
View Answer
A
Q326: What keyword is used in C++ to restrict automatic type conversion in constructors?
- A: implicit
- B: explicit
- C: auto
- D: final
View Answer
B
Q327: The function operator int() in the String class converts a String object to which type?
- A: char *
- B: int
- C: double
- D: float
View Answer
B
Q328: Which operator is overloaded to convert a String object to a char * in the String class?
- A: operator int()
- B: operator float()
- C: operator char *()
- D: operator void()
View Answer
C
Q329: When overloading a unary operator as a member function, how many parameters does it take?
- A: None
- B: One
- C: Two
- D: Three
View Answer
A
Q330: Which of the following is a drawback of type conversion operators in C++?
- A: They are too complex to implement
- B: They cause unexpected conversions
- C: They are inefficient
- D: They cannot be overloaded
View Answer
B