Question
The following questions are designed to use an interface in a system, which needs to print customized welcome message. For example, the welcome message to
The following questions are designed to use an interface in a system, which needs to print customized welcome message. For example, the welcome message to Sue will be "Dear Sue, welcome!"
1. What is wrong with the following interface?
public interface Welcome {
String name;
void greeting() {
System.out.println("Dear " + name + ", welcome!");
}
}
2. Fix the interfance in question 1.
3. After fixing the interface in, define a class implmenting the Welcome interface which can embed a name in a welcome message then print it to console.
4. Use the class defined in question 3 to create an object. Use the object to print a welcome message to you, which means your name should be embedded in the print welcome message.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started