21. Write a Java program to show the following. Create an interface called Vehicle. The vehicle interface has 3 methods namely, - Mileage - NumberOfPassengers
21. Write a Java program to show the following. Create an interface called Vehicle. The vehicle interface has 3 methods namely,
- Mileage
- NumberOfPassengers
- VehicleName
Create a class called Car which implements Vehicle interface. Write the implementation for the methods Mileage, NumberOfPassengers, VehicleName inside Car class. Mileage method implementation in Car class has a variable to hold mileage which is of datatype integer. NumberOfPassengers method implementation in Car class has an integer variable to hold the number of passengers traveling in the car. VehicleName method implementation in Car class has a String variable to hold the Car name. Create an object for Car class and print the implementation of Mileage, NumberOfPassengers, VehicleName methods.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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