Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q301: To display a complex number using the << operator, the output will be in the format:
- A: (real, img)
- B: real + img
- C: img, real
- D: real - img
View Answer
A
Q302: The cin object in C++ is used for ______ input.
- A: Integer
- B: Floating-point
- C: Character
- D: Console
View Answer
D
Q303: Which operator is overloaded to change a single character in a string in the modified String class?
- A: Subscript [] Operator
- B: Stream Insertion Operator
- C: Stream Extraction Operator
- D: Function () Operator
View Answer
A
Q304: What does the SetChar function do in the modified String class?
- A: Changes the entire string
- B: Changes a single character
- C: Deletes the string
- D: Allocates a new buffer
View Answer
B
Q305: What is the purpose of the operator() in the modified String class?
- A: Change the string
- B: Perform a generic operation
- C: Concatenate strings
- D: Reverse the string
View Answer
B
Q306: What will be the output of the following code: String s1("Ping"); s1.SetChar('o', 2); cout << s1.GetString();
- A: Pong
- B: Ping
- C: Pung
- D: Pang
View Answer
A
Q307: In the modified String class, what does the operator() function return?
- A: Integer
- B: Character
- C: String
- D: Boolean
View Answer
B
Q308: What is the advantage of using the subscript [] operator in the modified String class?
- A: It is more efficient
- B: It allows string concatenation
- C: It prevents buffer overflow
- D: It makes the code more complex
View Answer
A
Q309: Which of the following operators is used for substring operations in the modified String class?
- A: Subscript [] Operator
- B: Stream Insertion Operator
- C: Function () Operator
- D: Unary Operator
View Answer
C
Q310: The subscript [] operator in the modified String class must be overloaded as a ______.
- A: Friend function
- B: Member function
- C: Static function
- D: Global function
View Answer
B