This repository is a student learning portfolio for Object-Oriented Programming (OOP) in Java. It contains clean, readable examples that demonstrate core OOP concepts without turning the project into an over-engineered framework.
I am building this as part of my GitHub student portfolio for bursaries, internships, graduate programmes, and future Honours opportunities.
OOP is important for writing organised, reusable, and maintainable code. This repository helps me practise Java fundamentals in a way that I can explain clearly.
This foundation repo covers:
- Classes and objects
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
- Interfaces
| Concept | Example Folder | What It Shows |
|---|---|---|
| Classes and objects | src/classes_objects |
Creating objects, constructors, getters, setters, and toString |
| Encapsulation | src/encapsulation |
Protecting fields and using methods to control changes |
| Inheritance | src/inheritance |
Reusing and extending superclass behaviour |
| Polymorphism | src/polymorphism |
Overriding, overloading, and superclass references |
| Abstraction | src/abstraction |
Abstract classes and required subclass behaviour |
| Interfaces | src/interfaces |
Classes implementing a shared contract |
object-oriented-programming-java/
|-- README.md
|-- notes/
| `-- oop-principles.md
`-- src/
|-- abstraction/
| |-- Car.java
| |-- Motorcycle.java
| |-- Vehicle.java
| `-- VehicleTest.java
|-- classes_objects/
| |-- Student.java
| `-- StudentTest.java
|-- encapsulation/
| |-- BankAccount.java
| `-- BankAccountTest.java
|-- inheritance/
| |-- InheritanceTest.java
| |-- Lecturer.java
| |-- Person.java
| `-- StudentPerson.java
|-- interfaces/
| |-- AcademicReport.java
| |-- InterfaceTest.java
| `-- Reportable.java
`-- polymorphism/
|-- CardPayment.java
|-- CashPayment.java
|-- Payment.java
`-- PaymentTest.java
From the repository root, compile all current examples into an out folder:
mkdir out
javac -d out src/classes_objects/*.java src/encapsulation/*.java src/inheritance/*.java src/polymorphism/*.java src/abstraction/*.java src/interfaces/*.javaRun a specific test class:
java -cp out classes_objects.StudentTest
java -cp out encapsulation.BankAccountTest
java -cp out inheritance.InheritanceTest
java -cp out polymorphism.PaymentTest
java -cp out abstraction.VehicleTest
java -cp out interfaces.InterfaceTestIf you are using VS Code or IntelliJ, open the repository folder and run any test class with a main method.
- How classes model real-world objects.
- How constructors create objects with starting values.
- How encapsulation protects fields from unsafe changes.
- How inheritance lets related classes share common behaviour.
- How polymorphism lets the same method call behave differently.
- How abstract classes and interfaces define expected behaviour.
This repository currently focuses on OOP foundations. Future improvements may include:
- Student Management System mini-project
- Bank Account Simulation mini-project
- Exception handling
- File handling with objects
- UML class diagrams
- Basic unit tests