Skip to content

Awungia112/learning-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Java OOP Exercises

This project contains a collection of Java Object-Oriented Programming exercises that demonstrate the four main pillars of OOP:

  • Classes
  • Objects
  • Encapsulation
  • Inheritance
  • Polymorphism

Exercises Included

Part 1: Car Class

  • Demonstrates basic class creation with private fields
  • Shows encapsulation through getters and setters
  • Includes a constructor and display method

Part 2: ElectricCar Class

  • Demonstrates inheritance by extending the Car class
  • Adds new fields and methods specific to electric cars
  • Shows method overriding

Part 3: Polymorphism

  • Demonstrates polymorphism through method overloading
  • Shows how a method can work with different types of objects

Part 4: Zoo Application

  • Creates a hierarchy of animal classes
  • Demonstrates method overriding in subclasses
  • Shows how to work with collections of different object types

Bonus Challenge: Shape Classes

  • Creates an abstract Shape class
  • Implements concrete Circle and Rectangle classes
  • Demonstrates abstract methods and inheritance

How to Run

  1. Compile all Java files:

    javac src/*.java
  2. Run the Main class:

    java -cp src Main

The program will demonstrate all the OOP concepts through practical examples.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages