Question: LAB 3.4: Aggregation vs Composition PROGRAM 4 // Java Program to Illustrate Difference between Aggregation and Composition // Class 1 // Engine class which will


LAB 3.4: Aggregation vs Composition PROGRAM 4 // 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 of car has been started "); \} // Class 2 // Engine class class Car \& // Composition private Engine engine; // Constructor Car(Engine engine) this.engine = engine; 1 public void move () f engine. work(); System.out.println("Car is moving "); 1 \} 1. Compile and run the program to get the output. Explain the output. 2. Draw the UML class diagram relationships for the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
