Answer to Question #282551 in Java | JSP | JSF for koi

Question #282551

1. Write a simple Java application that will declare the class shown in the UML diagram below.

- The method displayMessage() function should show a welcome message together

with the course name (i.e “Welcome to Java Programming”).

- Create three objects and initialize their course names to: Calculus, C Programming

and Business Ethics.

- Display a welcome message for all the three courses.


1
Expert's answer
2021-12-25T01:47:50-0500
public class Course {
    private String courseName;

    public Course(String courseName) {
        this.courseName = courseName;
    }

    public void displayMessage() {
        System.out.println("Welcome to " + courseName);
    }
}


public class Main {
    public static void main(String[] args) {
        Course calculus = new Course("Calculus");
        Course c = new Course("C Programming");
        Course businessEthics = new Course("Business Ethics");
        calculus.displayMessage();
        c.displayMessage();
        businessEthics.displayMessage();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog