This project contains a collection of Java Object-Oriented Programming exercises that demonstrate the four main pillars of OOP:
- Classes
- Objects
- Encapsulation
- Inheritance
- Polymorphism
- Demonstrates basic class creation with private fields
- Shows encapsulation through getters and setters
- Includes a constructor and display method
- Demonstrates inheritance by extending the Car class
- Adds new fields and methods specific to electric cars
- Shows method overriding
- Demonstrates polymorphism through method overloading
- Shows how a method can work with different types of objects
- Creates a hierarchy of animal classes
- Demonstrates method overriding in subclasses
- Shows how to work with collections of different object types
- Creates an abstract Shape class
- Implements concrete Circle and Rectangle classes
- Demonstrates abstract methods and inheritance
-
Compile all Java files:
javac src/*.java -
Run the Main class:
java -cp src Main
The program will demonstrate all the OOP concepts through practical examples.