-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path21_Default Methods
59 lines (53 loc) · 1.44 KB
/
21_Default Methods
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
package com.company; // This file has some errors
interface Camera{
void takeSnap();
void recordVideo();
//void phoneNumber();
private void greet(){
System.out.println("Good Morning");
}
default void record4KVideo(){
greet();
System.out.println("Recording in 4K");
}
}
interface Wifi{
String[] getNetworks();
void connectToNetwork(String network);
}
class CellPhone{
void callNumber(int phoneNumber){
System.out.println("Calling" + phoneNumber);
}
void pickCall(){
System.out.println("Connecting..");
}
}
class SmartPhone extends CellPhone implements Wifi, Camera{
public void takeSnap(){
System.out.println("Taking Snap");
}
public void recordVideo(){
System.out.println("Taking Video");
}
public String[] getNetworks(){
System.out.println("Getting list of networks");
return new String[]{"PM", "GG", "SS"};
}
public String[] getNetworks() {
return new String[0];
}
public void connectToNetwork(String network) {
System.out.println("Connecting to " +network);
}
}
public class Default_methods {
public static void main(String[] args) {
SmartPhone sp = new SmartPhone();
String[] ar = sp.getNetworks();
for (String item:ar){
System.out.println(item);
}
sp.record4KVideo();
}
}