Final answer:
The correct answer is option C. To solve this problem, you need to implement a method in the Invitation class that takes in the name of a person as a parameter and returns a string consisting of the person's name, the host's name, and the event location.
Step-by-step explanation:
The correct answer is option C.
To solve this problem, you need to implement a method in the Invitation class that takes in the name of a person as a parameter and returns a string consisting of the person's name, the host's name, and the event location.
public String invitePerson(String name) {
return name + " is invited by " + hostName + " to the event at " + address;}
In this method, you concatenate the input name, hostName, and address using the '+' operator to form the desired string.
For example, if the hostName is "John", the address is "123 Main St", and the input name is "Alice", the method will return "Alice is invited by John to the event at 123 Main St".