
Simple coding example for Inheritance
Simple coding example for Bank system: A Bank Account has common features like accountNumber, balance, deposit(), withdraw(). Different types of accounts such as Savings Account and Current Account have additional features. Parent class: BankAccount child class1: SavingAccount child class2: CurrentAccount package bank.task ; public class BankAccount { int accountNumber ; double balance ; public void deposit ( double depositAmount , int accNo , String AccType ) { double total = balance + depositAmount ; System . out . println ( "An amount of Rs." + depositAmount + " has been deposited succesfully " ); System . out . println ( "The total amount in your " + AccType + " Account of Account number" + accNo + " is " + total ); } protected void withdraw ( double withdrawAmount , int accNo , String AccType ) { double total = balance - withdrawAmount ; System . out . println ( "An amount of Rs." + withdrawAmount + " has been withdrawn succesfully " ); System . out . println ( "The total amount i
Continue reading on Dev.to Tutorial
Opens in a new tab



