Question: 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
java code 3. Create an abstract class called 'Vehicle' that has two

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

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!