Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

9. Mohawk Industries Inc.

Answered: 1 week ago

Question

8. Satyam Computer Services Limited

Answered: 1 week ago