Understanding the important real world abstract class

Java Programming Language / Polymorphism in Java

1149

Program:

 abstract class Bank{
	abstract int getRateOfInterest();
	}

class CANARA extends Bank{
	int getRateOfInterest(){
		return 8;
		}
	}
class BORADA extends Bank{
	int getRateOfInterest(){
		return 9;
		}
	}

class BankInterest{
public static void main(String args[]){
	Bank b;
	b=new CANARA();
	System.out.println("Rate of Interest is: "+b.getRateOfInterest()+" %");
	b=new BORADA();
	System.out.println("Rate of Interest is: "+b.getRateOfInterest()+" %");
	}
}

Output:

Rate of Interest is: 8 %
Rate of Interest is: 9 %
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.