CJCoding With Joseph
15free / daySign inCreate account

Overloaded Area Methods

Method overloading means two methods can share a name if their parameter lists differ. Write TWO methods both named area:
- 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. For area(5) it prints 25, and for area(4, 6) it prints 24.

Expected Output:

25
24

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
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.