Question: Task 1 ) Abstract Class [ 1 5 pts ] Create an abstract class named Vehicle with the following attributes and methods: Attribute ( protected

Task 1) Abstract Class [15 pts]
Create an abstract class named Vehicle with the following attributes and methods:
Attribute (protected, String): model
Constructor: Vehicle(String model)
Abstract method (public void): accelerate()
Abstract method (public void): startEngine()
Abstract method (public void): stopEngine()
Task 2) Interface [10 pts]
Define an interface named Flyable with a method fly(). This interface should be implemented by classes representing vehicles capable of flying.
Task 3) Subclasses [25 pts]
Create two subclasses of Vehicle.
Car: Implement the abstract methods to print a message indicating acceleration, starting the engine, and stopping the engine.
Airplane: Implement the abstract methods to print a message indicating takeoff speed, starting the engine, and stopping the engine. Additionally, Implement the fly() method to print a message indicating the airplane is flying.
Task 4) Polymorphism [40 pts]
Create a VehicleDemo.java class and in the main method:
Create an array of Vehicle objects and initialize it with two instances of Car objects and two instances of Airplane objects.
Iterate through the array and demonstrate polymorphism by calling the accelerate() method on each object.
For objects that implement the Flyable interface, also call the fly() method using downcasting.
Task 5) UML Diagram [10 pts]
Draw the UML diagrams of each class. Show the relationship between classes. Show me the code from task one to task 5 and also the uml diagram

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!