-
Notifications
You must be signed in to change notification settings - Fork 0
/
chit21.java
41 lines (29 loc) · 976 Bytes
/
chit21.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//~Consider a scenario where Bank is a class that provides functionality to get the rate of interest. However, the rate of interest varies according to banks. For example, SBI, ICICI and AXIS banks could provide 8%, 7%, and 9% rate of interest.
abstract class Bank {
public abstract float getRateOfInterest();
}
class SBI extends Bank {
public float getRateOfInterest() {
return 8.0f;
}
}
class ICICI extends Bank {
public float getRateOfInterest() {
return 7.0f;
}
}
class AXIS extends Bank {
public float getRateOfInterest() {
return 9.0f;
}
}
public class chit21 {
public static void main(String[] args) {
Bank sbi = new SBI();
System.out.println("SBI: " + sbi.getRateOfInterest());
Bank icici = new ICICI();
System.out.println("ICICI: " + icici.getRateOfInterest());
Bank axis = new AXIS();
System.out.println("AXIS: " + axis.getRateOfInterest());
}
}