Alice has a class that includes a function to compute the area. She wants this function to compute the area for both circles (given radius) and rectangles (given length and breadth). Which concept can help her achieve this without renaming the functions?

  • Function overloading
  • Function overriding
  • Operator overloading
  • Polymorphism
Alice can achieve this using the concept of polymorphism, specifically method overloading. By overloading the computeArea function with different parameter types (radius for circles and length and breadth for rectangles), she can have a single function name that behaves differently based on the input, without renaming the functions.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *