forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCovariantReturnTypes.java
More file actions
49 lines (49 loc) · 972 Bytes
/
CovariantReturnTypes.java
File metadata and controls
49 lines (49 loc) · 972 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
class Flower{
public String whats_Your_Name(){
return "I have many names and types";
}
}
class Jasmine extends Flower{
@Override
public String whats_Your_Name(){
return "Jasmine";
}
}
class Lily extends Flower{
@Override
public String whats_Your_Name(){
return "Lily";
}
}
class Lotus extends Flower{
@Override
public String whats_Your_Name(){
return "Lotus";
}
}
class State{
public Flower your_National_Flower(){
return new Flower();
}
}
class WestBengal extends State{
@Override
public Flower your_National_Flower(){
Flower j = new Jasmine();
return j;
}
}
class Karnataka extends State{
@Override
public Flower your_National_Flower(){
Flower l = new Lotus();
return l;
}
}
class AndhraPradesh extends State{
@Override
public Flower your_National_Flower(){
Flower l = new Lily();
return l;
}
}