-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTut23.java
More file actions
87 lines (69 loc) · 1.33 KB
/
Tut23.java
File metadata and controls
87 lines (69 loc) · 1.33 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package tutorial;
//Interface
interface Mobile {
public int Camera();
default void Location() {
System.out.println("Boisar");
}
}
//inheritance in interface
interface Glass extends Mobile {
public void glassQuality();
public int Camera();
}
// polymorphism in interface
interface A {
public void amethod();
}
interface B {
public void bmethod();
}
interface C {
public void cmethod();
}
class polyinterface implements A, B, C {
@Override
public void cmethod() {
System.out.println("C method called");
}
@Override
public void bmethod() {
System.out.println("B method Called");
}
@Override
public void amethod() {
System.out.println("A Method Called");
}
public void priting() {
// polymorphism
A a = new polyinterface();
a.amethod();
B b = new polyinterface();
b.bmethod();
bmethod();
}
}
public class Tut23 implements Glass {
public static void main(String[] args) {
Tut23 tt = new Tut23();
System.out.println(tt.Camera());
tt.Location();
tt.glassQuality();
polyinterface pt = new polyinterface();
pt.priting();
Glass b = new Tut23();
System.out.println(b.Camera());
b.Location();
Mobile a = new Tut23();
System.out.println(a.Camera());
a.Location();
}
@Override
public int Camera() {
return 45;
}
@Override
public void glassQuality() {
System.out.println("Better");
}
}