- A beginner-friendly Java OOP project that models a simple Vehicle Management System.
- It focuses on demonstrating Encapsulation, Inheritance, Method Overriding and Upcasting/Downcasting in real-world scenarios using
CarandBikeclasses.
To create a mini Java application that manages different vehicle types and showcases:
- Encapsulation through private fields & getters/setters
- Inheritance with a
Vehiclebase class and specializedCar&Bikeclasses - Method overriding for vehicle-specific details
- Upcasting and safe downcasting
Vehicleclass has private fields:brand(String)speed(int)
- Public getter & setter methods control access.
- Subclasses:
Carβ extra field:fuelType(String)Bikeβ extra field:engineCC(int)
- Each subclass overrides
showDetails()to print vehicle-specific data.
- Upcasting: Treat
CarorBikeobjects asVehiclereferences. - Downcasting: Access subclass-specific fields safely after type checking.
βββ src/
β βββ vms/
β βββ Vehicle.java
β βββ Car.java
β βββ Bike.java
β βββ Main.java
β βββ module-info.java
βββ bin/ # Compiled .class files
βββ .classpath
βββ .project
βββ README.md
βββ .settings/- Eclipse
The car fuel type is petrol
The engine cc of bike is 250
Enfield
100