Java Lesson 30 – OOP Mini Project | Dataplexa

OOP Mini Project – Bank Account Management System

In this lesson, we will build a small but realistic Java application using core object-oriented programming concepts. This mini project helps you understand how OOP is used in real applications, not just in theory.

We will design a simple Bank Account Management System that supports basic operations such as deposit, withdrawal, and balance checking.


What Concepts Are Used in This Project?

This mini project uses the following Java concepts:

  • Classes and Objects
  • Encapsulation
  • Inheritance
  • Method Overriding
  • Abstraction
  • Polymorphism

If you understood the previous lessons, this project will feel natural.


Project Scenario

We want to design a banking system where:

  • All accounts share common behavior
  • Different account types handle interest differently
  • Account balance is protected from direct access

To achieve this, we will use an abstract class and child classes.


Step 1: Create an Abstract BankAccount Class

This class defines the structure that all bank accounts must follow.


abstract class BankAccount {

    private double balance;

    public BankAccount(double balance) {
        this.balance = balance;
    }

    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
        }
    }

    public void withdraw(double amount) {
        if (amount > 0 && amount <= balance) {
            balance -= amount;
        }
    }

    public double getBalance() {
        return balance;
    }

    abstract void calculateInterest();
}

Notice how the balance is protected using private and accessed only through methods.


Step 2: Create a SavingsAccount Class

Savings accounts earn interest, so we override the interest method.


class SavingsAccount extends BankAccount {

    public SavingsAccount(double balance) {
        super(balance);
    }

    void calculateInterest() {
        System.out.println("Interest calculated at 4%");
    }
}

Step 3: Create a CurrentAccount Class

Current accounts usually do not earn interest.


class CurrentAccount extends BankAccount {

    public CurrentAccount(double balance) {
        super(balance);
    }

    void calculateInterest() {
        System.out.println("No interest for current accounts");
    }
}

Step 4: Test the Application

Now let’s test the system using polymorphism.


public class Main {
    public static void main(String[] args) {

        BankAccount acc1 = new SavingsAccount(5000);
        BankAccount acc2 = new CurrentAccount(8000);

        acc1.deposit(1000);
        acc1.withdraw(2000);
        acc1.calculateInterest();

        System.out.println("Savings Balance: " + acc1.getBalance());

        acc2.withdraw(3000);
        acc2.calculateInterest();

        System.out.println("Current Balance: " + acc2.getBalance());
    }
}

Expected Output


Interest calculated at 4%
Savings Balance: 4000.0
No interest for current accounts
Current Balance: 5000.0

How This Project Uses OOP Correctly

  • Encapsulation protects account balance
  • Abstraction defines a common structure
  • Inheritance avoids code duplication
  • Polymorphism allows flexible behavior

This is the same design approach used in real banking software.


Try This Yourself

As practice, try extending this project by:

  • Adding a fixed deposit account
  • Adding transaction history
  • Adding validation messages

Practicing small extensions like this builds real Java confidence.


Key Takeaways

  • OOP concepts work together, not in isolation
  • Real applications rely on abstraction and encapsulation
  • Polymorphism makes systems flexible
  • Mini projects are the best way to master Java

In the next lesson, we will move into the Java Collections Framework, which is heavily used in professional Java development.