CJCoding With Joseph
15free / daySign inCreate account

Overloading means two methods share a name but take different parameters. FormalGreeter inherits greet() with no parameters from Greeter, and adds a second greet that takes a name. The inherited one is not replaced: both can be called on a FormalGreeter. Complete the overload.

Requirements: 1. greet(String name) returns the text of the inherited greet(), then a comma and a space, then name. With the name Sam that gives Hello, Sam. 2. Get the first part by calling greet() with no arguments. Do not type the word Hello yourself: a test changes what greet() returns and expects your method to follow it.

The Greeter class is provided. Do not change it.

Do NOT write a main method.

Expected output

Hello
Hello, Sam
Hello, Dr. Lee

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

Hints3 available
Topics
InheritanceClasses
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.