← Back to Methods
Question 257
Overloaded Area Methods
Overloaded Area Methods
Method overloading means two methods can share a name if their parameter lists differ. Write TWO methods both namedarea: -area(int side)returns the area of a square (side times side) -area(int width, int height)returns the area of a rectangle (width times height) The program calls both. Forarea(5)it prints 25, and forarea(4, 6)it prints 24.
Expected Output:
25 24
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Methods
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.