Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java code 3. Create an abstract class called 'Vehicle' that has two fields: 'make' and 'model'. The 'Vehicle' class should have a constructor that takes

java code
image text in transcribed
3. Create an abstract class called 'Vehicle' that has two fields: 'make' and 'model'. The 'Vehicle' class should have a constructor that takes in the 'make' and 'model' as arguments and sets their values. The 'Vehicle' class should also have an abstract method called 'getinfo' that returns a string containing the make and model of the vehicle. Create two subclasses of 'Vehicle' called 'Car' and 'Truck' that override the 'getlnfo' method to return a string containing the make and model of the dar or truck, respectively. The 'Car' and 'Truck' classes should also have a method called 'getCapacity' that returns an integer indicating the number of passengers or cargo the car or truck can hold, respectively. Create a main method that creates instances of the 'Car' and 'Truck' classes and calls their 'getlnfo' and 'getCapacity' methods using polymorphism

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Distinguish between formal and informal reports.

Answered: 1 week ago

Question

6. Discuss the steps involved in conducting a task analysis.

Answered: 1 week ago