Question: Task 1 ) Abstract Class [ 1 5 pts ] Create an abstract class named Vehicle with the following attributes and methods: Attribute ( protected
Task Abstract Class pts
Create an abstract class named Vehicle with the following attributes and methods:
Attribute protected String: model
Constructor: VehicleString model
Abstract method public void: accelerate
Abstract method public void: startEngine
Abstract method public void: stopEngine
Task Interface pts
Define an interface named Flyable with a method fly This interface should be implemented by classes representing vehicles capable of flying.
Task Subclasses 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 Polymorphism 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 UML Diagram pts
Draw the UML diagrams of each class. Show the relationship between classes. Show me the code from task one to task and also the uml diagram
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
