Overloaded Area Methods
mediumQuestion 145Method overloading means two methods can share a name if their parameters differ. Write TWO static methods named Area:
- Area(int side) returns side * side (a square)
- Area(int width, int height) returns width * height (a rectangle)
Do NOT write a Main method. For Area(5) it prints 25; for Area(4, 6) it prints 24.
Expected output
25 24
= newline. The output ends with a newline, so 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 (cw, cr, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.