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.
Loading...
Related Quiz
- In binary file operations, to write data of various data types, you use the _______ function.
- What is the primary purpose of the do-while loop?
- In terms of precedence, the operator ______ has higher precedence than the && operator.
- The bitwise NOT operator (~) performs a _______ operation on each bit of a number.
- What potential issue might arise when using switch-case statements with enumerated types?