By the end of this week, learners will be able to:
-
Grasp the principles of Object-Oriented Programming (OOP)
-
Apply real-world financial logic using Java classes and objects
-
Construct reusable financial components using constructors and the
thiskeyword -
Structure applications using object methods and encapsulation
Topics:
-
Core OOP principles: Abstraction, Encapsulation, Inheritance, Polymorphism
-
Classes vs Objects
-
Real-world financial analogies (Class = BankAccount blueprint, Object = your actual savings account)
Code Example:
class BankAccount { private String accountHolder; private double balance;public void setDetails(String name, double bal) { this.accountHolder = name; this.balance = bal; } public void showBalance() { System.out.println("Account Holder: " + accountHolder); System.out.println("Balance: ₹" + balance); }}
public class Main { public static void main(String[] args) { BankAccount acc = new BankAccount(); acc.setDetails("Ravi", 12000); acc.showBalance(); } }
Classroom Activity:
- Create a
DigitalWalletclass with private fieldsownerName,amount, and a methodcheckBalance().
Topics:
-
Constructors (default & parameterized)
-
thiskeyword -
Benefits of encapsulation in financial applications
Code Example:
class LoanAccount { private String loanType; private double amount;LoanAccount(String loanType, double amount) { this.loanType = loanType; this.amount = amount; } public void displayDetails() { System.out.println("Loan Type: " + loanType); System.out.println("Amount: ₹" + amount); }
}
Task:
- Create a
FixedDepositclass withname,principalAmount, anddurationInYears. Include a parameterized constructor and adisplay()method.
Topics:
-
Writing financial calculation methods
-
Understanding method parameters & return types
-
Basic math in Java
Code Example:
class EMICalculator { public double calculateEMI(double principal, double rate, int time) { return (principal * rate * time) / 100; } }
public class Main { public static void main(String[] args) { EMICalculator emi = new EMICalculator(); double result = emi.calculateEMI(100000, 10, 2); System.out.println("Calculated EMI: ₹" + result); } }
Mini Challenge:
-
Create a
CurrencyConverterclass with methods:-
toINR(double usd) -
toUSD(double inr) -
Assume USD to INR = 83
-
Task: Create a fully functional BankAccount class with:
-
Fields:
accountNumber,accountHolder,balance -
Methods:
deposit(double amount),withdraw(double amount),printDetails() -
Prevent overdraft (balance should not go negative)
Expected Output:
Account Holder: Aditi
Account Number: 123456
Balance: ₹5000.0
MCQs:
-
What is the benefit of using constructors?
-
What does the
thiskeyword refer to? -
What is method overloading and is it supported in Java?
-
What access modifier is best used for encapsulation?
Assignment: Build a Transaction class:
-
Fields:
amount,type(“credit” or “debit”),timestamp -
Use
java.time.LocalDateTimefor timestamp -
Constructor &
displayTransaction()method -
main()method to create and display 3 transactions
Marks Distribution:
-
10 points - BankAccount class (encapsulation, logic)
-
10 points - Transaction class (constructor, timestamp handling)
-
10 points - Quiz (MCQs + 1 coding snippet)
Submission Method:
-
Upload
.javafiles or GitHub repo link -
Optional: Submit a 2-3 minute video explaining your code and logic