-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterDefMain.java
More file actions
39 lines (33 loc) · 955 Bytes
/
InterDefMain.java
File metadata and controls
39 lines (33 loc) · 955 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
// ELY-DefInterInherit/InterDefMain.java
public class InterDefMain
implements InterDef1, InterDef2 {
// those were abstract; implementation required
@Override
public void abs1() {
System.out.println("abs1");
}
@Override
public void abs2() {
System.out.println("abs2");
}
// overriding necessary, as two versions inherited
@Override
public String getName() {
return "From 1: " + InterDef1.super.getName() +
"\nFrom 2: " + InterDef2.super.getName();
}
// we may override but we don't have to...
@Override
public void specific2() {
InterDef2.super.specific2();
System.out.println(" corrected");
}
public static void main (String[] args) {
InterDefMain m = new InterDefMain();
m.abs1();
m.abs2();
System.out.println(m.getName());
m.specific1();
m.specific2();
}
}