Java class definition create Bank class
// basic OOP syntax class BankAccount { private double balance; // account balance public BankAccount(double openingBalance) // constructor {/*from ww w . java 2 s.c o m*/ balance = openingBalance; } public void deposit(double amount) // makes deposit { balance = balance + amount; } public void withdraw(double amount) // makes withdrawal { balance = balance - amount; } public void display() // displays balance { System.out.println("balance=" + balance); } } public class Main { public static void main(String[] args) { BankAccount ba1 = new BankAccount(100.00); System.out.print("Before transactions, "); ba1.display(); ba1.deposit(74.35); // make deposit ba1.withdraw(20.00); // make withdrawal System.out.print("After transactions, "); ba1.display(); } }