forked from pray3m/JavaPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimePolymorphismDemo.java
More file actions
37 lines (32 loc) · 869 Bytes
/
Copy pathRuntimePolymorphismDemo.java
File metadata and controls
37 lines (32 loc) · 869 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
/* 11. Complete the program in java that demonstrate the concepts of method overriding and run
time polymorphism. */
class Bank{
float getRateOfInterest(){
return 0;
}
}
class NICASIA extends Bank{
float getRateOfInterest() {
return 8.4f;
}
}
class PRABHU extends Bank{
float getRateOfInterest() {
return 7.3f;
}
}
class MEGA extends Bank{
float getRateOfInterest() {
return 9.5f;
}
}
public class RuntimePolymorphismDemo{
public static void main(String[] args){
Bank a=new NICASIA();
Bank b=new PRABHU();
Bank c=new MEGA();
System.out.println("NICASIA Rate of Interest: "+a.getRateOfInterest());
System.out.println("PRABHU Rate of Interest: "+b.getRateOfInterest());
System.out.println("MEGA Rate of Interest: "+c.getRateOfInterest());
}
}