CJCoding With Joseph

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
Topics:
Methods
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.