import java.*; import java.io.*; import java.util.*; abstract class Bank{ abstract void getRateOfInterest(); } class SBI extends Bank { Scanner sc = new Scanner(System.in); void getRateOfInterest() { System.out.print("Enter Your Amount of Interest : "); int balance = sc.nextInt(); int interest = (balance * 10)/100; System.out.println("10% Interest is : "+interest); } } class PNB extends Bank { Scanner sc = new Scanner(System.in); void getRateOfInterest() { System.out.print("Enter Your Amount of Interest : "); int balance = sc.nextInt(); int interest = (balance * 15)/100; System.out.println("15% Interest is : "+interest); } } class TestBank { public static void main(String args[]) { Bank s=new SBI();//if object is SBI, method of SBI will be invoked s.getRateOfInterest(); Bank p=new PNB();//if object is PNB, method of PNB will be invoked p.getRateOfInterest(); } }
OUTPUT Enter Your Amount of Interest : 10000 10% Interest is : 1000 Enter Your Amount of Interest : 10000 15% Interest is : 1000