-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalRuntimePolymorephism.java
More file actions
72 lines (45 loc) · 1.49 KB
/
Copy pathfinalRuntimePolymorephism.java
File metadata and controls
72 lines (45 loc) · 1.49 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
abstract class Account{
String accountHolderName;
String address;
String dob;
String phone;
public abstract int getIntrestRate();
public final void display() {
System.out.println("Account Type = "+this.getClass().getName());
System.out.println("accountHolderName = "+this.accountHolderName);
System.out.println("address = "+this.address);
System.out.println("dob = "+this.dob);
System.out.println("IntrestRate = "+this.getIntrestRate());
}
}
class SavingAccount extends Account{
public SavingAccount(String accountHolderName,String address,String dob,String phone ) {
this.accountHolderName =accountHolderName;
this.address =address;
this.dob=dob;
this.phone =phone;
}
public int getIntrestRate() {
return 3;
}
}
class CurrentAccount extends Account{
public CurrentAccount(String accountHolderName,String address,String dob,String phone ) {
this.accountHolderName =accountHolderName;
this.address =address;
this.dob=dob;
this.phone =phone;
}
public int getIntrestRate() {
return 0;
}
}
public class finalRuntimePolymorephism {
public static void main(String[] args) {
Account a1 =new SavingAccount("Himanshu","ABCD","01-01-2020","1234567895");
a1.display();
System.out.println("=========================================================");
Account a2 =new CurrentAccount("Shivani","ABCD","01-01-2020","1253591251");
a2.display();
}
}