forked from manav88/javaNS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverride.java
More file actions
43 lines (36 loc) · 940 Bytes
/
override.java
File metadata and controls
43 lines (36 loc) · 940 Bytes
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
42
43
class Bank {
int getRateOfInterest() {
return 0;
}
}
// Creating child classes.
class SBI extends Bank {
int getRateOfInterest() {
return 8;
}
}
class ICICI extends Bank {
int getRateOfInterest() {
return 7;
}
}
class AXIS extends Bank {
int getRateOfInterest() {
return 9;
}
}
class denabank extends Bank {
}
// Test class to create objects and call the methods
class Test2 {
public static void main(String args[]) {
SBI s = new SBI();
ICICI i = new ICICI();
AXIS a = new AXIS();
denabank d = new denabank();
System.out.println("SBI Rate of Interest: " + s.getRateOfInterest());
System.out.println("ICICI Rate of Interest: " + i.getRateOfInterest());
System.out.println("AXIS Rate of Interest: " + a.getRateOfInterest());
System.out.println("Dena Rate of Interest: " + d.getRateOfInterest());
}
}