OOP Lab Report
OOP Lab Report
Output:
Problem 02: Write down a Java program creating a class with private instance and
variable, account number, account holder’s name, date of birth, date of account
opening & balance. Implement encapsulation, public getter & setter methods in
such a way that the user cannot change their account balance themselves.
Code:
// BankAccount.java
package com.example.bankacc;
// Main.java
package com.example.bankacc;
public class Main {
public static void main(String[] args) {
BankAccount acc1 = new BankAccount("Mizanur Rahman",
"123456", "23/08/2001");
acc1.depositBalance(100);
System.out.println(acc1.getBalance());
acc1.withdrawBalance(60);
System.out.println(acc1.getBalance());
}
}
Output: