-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathIfExtend.java
More file actions
40 lines (30 loc) · 713 Bytes
/
IfExtend.java
File metadata and controls
40 lines (30 loc) · 713 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
package chapter9;
//One interface can extend another
interface A2 {
void meth1();
void meth2();
}
//B2 now includes meth1() and meth2() -- it adds meth3();
interface B2 extends A2 {
void meth3();
}
//This class must implement all of A2 and B2
class MyClass implements B2 {
public void meth1() {
System.out.println("Implement meth1()");
}
public void meth2() {
System.out.println("Implement meth2()");
}
public void meth3() {
System.out.println("Implement meth3()");
}
}
public class IfExtend {
public static void main(String[] args) {
MyClass ob = new MyClass();
ob.meth1();
ob.meth2();
ob.meth3();
}
}