Answered step by step
Verified Expert Solution
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
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
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