Question: 1. Compile and run the program to get the output. Explain the output. 2. Draw the UML class diagram relationships for the program //

1. Compile and run the program to get the output. Explain the   output. 2. Draw the UML class diagram relationships for the program // 

1. Compile and run the program to get the output. Explain the output. 2. Draw the UML class diagram relationships for the program // Java Program to Illustrate Difference between Aggregation and Composition // Class 1 // Engine class which will be used by car // and Car class will have a field/attribute of Engine type. class Engine { // Method to starting an engine public void work() { System.out.println("Engine } // Class 2 // Engine class class Car ( // Composition private Engine engine; // Constructor Car (Engine engine) { this.engine - engine; } public void move () { of car has been started "); engine.work(); System.out.println("Car is moving "); } } // Class 3 // Main class public class Main() public static void main(String[] args) { // Making an engine by creating // an instance of Engine class. Engine engine - new Engine(); // Making a car with engine // passing a engine instance as an argument // while creating instance of Car Car car- new Car (engine); // Making car to move //by calling move () method inside main() car.move(); }}

Step by Step Solution

3.40 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

When the program is compiled and run it will output the following PATIENT INFORMATION Name Yaya Addr... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!