Model Savings and Current Accounts With Overridable Withdrawal Rules
Last updated: November 29, 2026
Quick Overview
Design a small class hierarchy for bank accounts where savings accounts enforce a minimum balance and earn monthly interest, current accounts allow an overdraft up to a limit, and the shared withdraw method stays in the base class.
TCS
November 29, 20260
0
0 solved
Design a small class hierarchy for bank accounts where savings accounts enforce a minimum balance and earn monthly interest, current accounts allow an overdraft up to a limit, and the shared withdraw method stays in the base class.
OOP questions are standard in TCS technical interviews for freshers, and a banking domain is natural given BaNCS and the firm's banking clients. The interviewer is checking encapsulation, inheritance versus duplication, and whether the candidate knows the template method idea without having to name it.
What the Interviewer Expects
- Keep the balance private and expose it read-only
- Put validation and history recording in one base withdraw method
- Let subclasses override only the rule that differs
- Raise a specific exception rather than returning magic values
- Store money as integer minor units
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Would you use an abstract class or an interface for Account here, and why?
- How would you add a fixed deposit that forbids withdrawals before maturity?
- Where does thread safety belong if two ATMs hit the same account?
- How would you unit test the overdraft boundary?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Operations: deposit, withdraw, month-end processing, balance lookup. Savings: balance after withdrawal must stay at or above min_balance; credits monthly interest. Current: balance may go negative d...
High-Level Design
Account owns state, validation and history. The only varying piece is the question "is this withdrawal allowed?", so it lives in a protected hook _can_withdraw that subclasses override. `month_end...