Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started