- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolymorphismInInterfaces.java
More file actions
Latest commit
65 lines (58 loc) · 2.19 KB
/
Copy pathPolymorphismInInterfaces.java
File metadata and controls
65 lines (58 loc) · 2.19 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
interfaceMyCamera2{
voidtakeSnap();
voidrecordVideo();
privatevoidgreet(){
System.out.println("Good Morning");
}
defaultvoidrecord4KVideo(){
greet();
System.out.println("Recording in 4k...");
}
}
interfaceMyWifi2{
String[] getNetworks();
voidconnectToNetwork(Stringnetwork);
}
classMyCellPhone2{
voidcallNumber(intphoneNumber){
System.out.println("Calling "+ phoneNumber);
}
voidpickCall(){
System.out.println("Connecting... ");
}
}
classMySmartPhone2extendsMyCellPhone2implementsMyWifi2, MyCamera2{
publicvoidtakeSnap(){
System.out.println("Taking snap");
}
publicvoidrecordVideo(){
System.out.println("Taking snap");
}
// public void record4KVideo(){
// System.out.println("Taking snap and recoding in 4k");
// }
publicString[] getNetworks(){
System.out.println("Getting List of Networks");
String[] networkList = {"Harry", "Prashanth", "Anjali5G"};
returnnetworkList;
}
publicvoidconnectToNetwork(Stringnetwork){
System.out.println("Connecting to " + network);
}
publicvoidsampleMeth(){
System.out.println("meth");
}
}
publicclassPolymorphismInInterfaces {
publicstaticvoidmain(String[] args) {
MyCamera2cam1 = newMySmartPhone2(); // This is a smartphone but, use it as a camera
// cam1.getNetworks(); --> Not allowed
// cam1.sampleMeth(); --> Not allowed
cam1.record4KVideo();
MySmartPhone2s = newMySmartPhone2();
s.sampleMeth();
s.recordVideo();
s.getNetworks();
s.callNumber(7979);
}
}