Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q311: In the modified String class, the subscript [] operator returns a ______.
  • A: void
  • B: int
  • C: char &
  • D: float
View Answer
C

Q312: What will be the output of the following code: String s("Hello World"); cout << s(1, 5);
  • A: Hello
  • B: World
  • C: Hell
  • D: o World
View Answer
A

Q313: The Function () operator in the modified String class can take ______ number of parameters.
  • A: 1
  • B: 2
  • C: Any
  • D: None
View Answer
C

Q314: Unary operators generally act as ______.
  • A: Postfix only
  • B: Prefix only
  • C: Both prefix and postfix
  • D: None of the above
View Answer
C

Q315: In the modified String class, what is the general syntax for overloading a unary operator as a member function?
  • A: TYPE & operator OP();
  • B: TYPE & operator OP(TYPE &);
  • C: void operator OP(TYPE &);
  • D: static TYPE & operator OP();
View Answer
A

Q316: Which of the following unary operators can be overloaded in a similar way as the unary ‘-’ operator?
  • A: +
  • B: ++
  • C: --
  • D: All of the above
View Answer
A

Q317: The SetChar function checks if the position is valid by ensuring pos is greater than 0 and less than or equal to ______.
  • A: buffer length
  • B: string size
  • C: array size
  • D: integer value
View Answer
B

Q318: What is the default access specifier for members of a class in C++?
  • A: Public
  • B: Protected
  • C: Private
  • D: Default
View Answer
C

Q319: What will happen if you try to use the stream insertion operator << with a custom class without overloading it?
  • A: The program will compile successfully
  • B: A runtime error will occur
  • C: The program will throw a compile-time error
  • D: The program will print garbage values
View Answer
C

Q320: What does the post-increment operator (++) do?
  • A: Increments and returns the new value
  • B: Increments and returns the old value
  • C: Decrements and returns the old value
  • D: Decrements and returns the new value
View Answer
B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now