-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolymorphism_Interface.java
62 lines (52 loc) · 1.28 KB
/
Polymorphism_Interface.java
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
// Polymorphism in Interface
interface Camera{
void picture();
void record();
}
interface mediaPlayer{
void Playmusic();
void Playvideo();
}
class dabbaPhone{
void call(){
System.out.println("calling ....");
}
void sms(){
System.out.println("sending sms ....");
}
}
class tagdaPhone extends dabbaPhone implements Camera, mediaPlayer{
public void picture(){
System.out.println("click photo ....");
}
public void record(){
System.out.println("recording video ....");
}
public void Playmusic(){
System.out.println("Playing music ....");
}
public void Playvideo(){
System.out.println("Playing video ....");
}
public void Gps(){
System.out.println("Location turning on...");
}
}
public class Polymorphism_Interface {
public static void main(String[] args) {
mediaPlayer mp = new tagdaPhone();
/*mp.picture();
mp.record();*/ // ---> We can only use mediaPlayer method
mp.Playmusic();
mp.Playvideo();
tagdaPhone tp = new tagdaPhone();
// Now we can use all methods
tp.Gps();
tp.call();
tp.sms();
tp.picture();
tp.record();
tp.Playmusic();
tp.Playvideo();
}
}