Which OOP concept allows the same function name to perform different operations in different situations?

Options

  • A. Inheritance
  • B. Encapsulation
  • C. Polymorphism
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. Polymorphism

Detailed Explanation

Answer: Polymorphism

Polymorphism means "many forms". In C++, the same function or interface can behave differently depending on the situation.

Function overloading is an example of compile-time polymorphism, while virtual functions are commonly used to achieve run-time polymorphism.