abstract class Bank {
abstract int getRateOfInterest();
}
class SBI extends Bank {
int getRateOfInterest() {
return 7;
}
}
class PNB extends Bank {
int getRateOfInterest() {
return 8;
}
}
class TestBank {
public static void main(String args[]) {
Bank b;
b = new SBI();
System.out.println(“Rate of Interest is: " + b.getRateOfInterest() + " %”);
b = new PNB();
System.out.println(“Rate of Interest is: " + b.getRateOfInterest() + " %”);
}
}
Java
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)