-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupcasting
More file actions
57 lines (26 loc) · 641 Bytes
/
upcasting
File metadata and controls
57 lines (26 loc) · 641 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class Rbi{
public double getrateofint() {
return 5.0;
}
}
class Sbibank extends Rbi{
public double getrateofint() {
return 6.5;}
}
class Hdfc extends Rbi{
public double getrateofint() {
return 7.0;
}}
public class Inheritance {
public static void main(String[] args) {
Rbi r=new Rbi();
Rbi r1=new Sbibank();//upcasting
Hdfc h= new Hdfc();
double a=r.getrateofint();
double b =r1.getrateofint();
double c=h.getrateofint();
System.out.println("rbi int:"+a);
System.out.println("sbi int"+b);
System.out.println("hdfc int"+c);
}
}