Module 37: Java Capstone ProjectsBeginner30 min read
Capstone Project: Console Banking & Student Management System
Build a complete OOP-based Banking & Student Management application with encapsulated accounts, collections, exception handling, and transaction history.
Key Takeaways & Core Concepts
- Domain Layer:
BankAccountenforces balance invariants (rejecting negative deposits and overdrafts). - Service / Registry Layer:
HashMap<String, BankAccount>provides O(1) lookup by account ID. - Error Handling: Custom checked exceptions communicate business-rule failures cleanly to callers.
Project Overview
Real engineering mastery comes from combining multiple concepts into a cohesive system. This capstone integrates OOP, Encapsulation, Collections (HashMap, ArrayList), Custom Exceptions, and Java 8 Streams into a clean, layered Java application.
Complete Mini Banking System
1import java.util.*;
2
3class BankAccount {
4 private final String id;
5 private double balance;
6 BankAccount(String id, double initial) { this.id = id; this.balance = initial; }
7 void deposit(double amt) { if (amt > 0) balance += amt; }
8 boolean withdraw(double amt) {
9 if (amt > 0 && amt <= balance) { balance -= amt; return true; }
10 return false;
11 }
12 public String toString() { return id + " -> Rs." + balance; }
13}
14
15public class Main {
16 public static void main(String[] args) {
17 Map<String, BankAccount> accounts = new HashMap<>();
18 accounts.put("ACC101", new BankAccount("ACC101", 5000));
19 accounts.get("ACC101").deposit(2500);
20 accounts.get("ACC101").withdraw(1200);
21 System.out.println(accounts.get("ACC101"));
22 }
23}
Click code or "Edit Code" to edit
Interactive Code Block•Tab = 4 spaces•Ctrl + Enter = Run
23 lines
Note: Each `BankAccount` enforces its own balance invariant while `HashMap` provides O(1) lookup by account ID.
Learning Objectives & Architecture
- Domain Layer:
BankAccountenforces balance invariants (rejecting negative deposits and overdrafts). - Service / Registry Layer:
HashMap<String, BankAccount>provides O(1) lookup by account ID. - Error Handling: Custom checked exceptions communicate business-rule failures cleanly to callers.
Possible Improvements
- Persist accounts to disk with
Files.writeStringor MySQL using JDBCPreparedStatement. - Add JUnit 5 tests for deposit, withdrawal, and transfer edge cases.
- Expose operations as a Spring Boot REST API with
@RestController.
Practice & AssessmentJava Programming Tutorial
Test Your Understanding
Reinforce core concepts with interactive multiple-choice questions, live coding challenges, and top technical interview questions.
Your Current Score
0 / 0 correct(0 attempted)
Previous Lesson
Module 36: Advanced Java & Spring Boot Overview
Servlets, JSP, Sessions & Spring Boot Introduction
26 min read
Congratulations!
You completed all course lessons in this track!