-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceInheritenceTest.java
More file actions
52 lines (44 loc) · 1.12 KB
/
InterfaceInheritenceTest.java
File metadata and controls
52 lines (44 loc) · 1.12 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
package oop.interf.ext;
public class InterfaceInheritenceTest implements Showable, Readable {
public static void main(String[] args) {
InterfaceInheritenceTest obj = new InterfaceInheritenceTest();
obj.print();
obj.read();
obj.show();
System.out.println(obj.hashCode());
// ---------
Showable sObj = new InterfaceInheritenceTest();
sObj.print();
// sObj.read( ); //ERROR
sObj.show();
((Readable) sObj).read(); // OK
// ----------
Printable pObj = new InterfaceInheritenceTest();
pObj.print();
// pObj.read( );
// pObj.show( );
((Readable) pObj).read();
((Showable) pObj).show();
// ---------------
Readable rObj = new InterfaceInheritenceTest();
System.out.println(Readable.noOfPeopRead);
// rObj.print( );
rObj.read();
// rObj.show( );
// Casting to another interface.
((Printable) rObj).print();
((Showable) rObj).show();
}
@Override
public void print() {
System.out.println("PRINT");
}
@Override
public void read() {
System.out.println("READ");
}
@Override
public void show() {
System.out.println("SHOW");
}
}