-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay6_Interfaces.java
More file actions
297 lines (272 loc) · 5.53 KB
/
Day6_Interfaces.java
File metadata and controls
297 lines (272 loc) · 5.53 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
// Definations:
// 1.Any service requirement specification is considered as an interface
// 2.from client point of view an interface defines the set of services what he is expecting
// 3.from service provider point of view an interface defines as the set of services what he is offering
// 4.Inside interface every method is public and abstract whether we are declaring or not hence interface is considered as 100% pure abstract classes
// topics:
// 1.extends vs implements
// 2.class X extends Y implements Z
// 3.interface variables
// 4.method naming conflicts
// ---> For different implements
// 5.interface variable naming conflicts
// 6.Marker Interface
// 7.Adapter Class
// 8.Nested Interfaces
// interface Pavan
// {
// void m1(); //public abstract void m1(); or public void m1(); or abstract void m1();
// void m2();
// void m3();
// }
// class Test implements Pavan
// {
// public void m1()
// {
// System.out.println("Anna pavan");
// }
// public void m2(){}
// public void m3(){}
// }
// public class Day6_Interfaces
// {
// public static void main(String[] args)
// {
// Test t=new Test();
// t.m1();
// }
// }
// --------------------------------------------------------------------------------------
// 1.extends vs implements
// interface A
// {
// void m1();
// }
// interface B
// {
// void m2();
// }
// class Test implements A,B
// {
// public void m1()
// {
// System.out.println("m1");
// }
// public void m2()
// {
// System.out.println("m2");
// }
// }
// public class Day6_Interfaces
// {
// public static void main(String[] args)
// {
// }
// }
// ------------------------------------------------------------------------
// interface A
// {
// void m1();
// }
// interface B
// {
// void m2();
// }
// class Anna
// {
// public void m3()
// {
// System.out.println("m3");
// }
// }
// class Test extends Anna implements A,B
// {
// public void m1()
// {
// System.out.println("m1");
// }
// public void m2()
// {
// System.out.println("m2");
// }
// }
// public class Day6_Interfaces
// {
// public static void main(String[] args)
// {
// Test t = new Test();
// t.m1();
// t.m2();
// t.m3();
// }
// }
// ----------------------------------------------------------------
// interface A
// {
// void m1();
// }
// interface B
// {
// void m2();
// }
// interface C extends A,B
// {
// void m3();
// }
// class Test implements C
// {
// public void m1()
// {
// System.out.println("m1");
// }
// public void m2()
// {
// System.out.println("m2");
// }
// public void m3()
// {
// System.out.println("m3");
// }
// }
// public class Day6_Interfaces
// {
// public static void main(String[] args)
// {
// }
// }
// ------------------------------------------------------------------------
// interface variable
// interface A
// {
// int x=10;
// }
// public class Day6_Interfaces implements A
// {
// public static void main(String[] args)
// {
// x=100;
// }
// }
// --------------------------------------------------------
// interface A
// {
// int x=10;
// }
// interface B
// {
// int x=100;
// }
// public class Day6_Interfaces implements A,B
// {
// public static void main(String[] args)
// {
// // System.out.println(x); //reference to x is ambiguous
// System.out.println(A.x);
// System.out.println(B.x);
// }
// }
// -----------------------------------------------------------------------
// interface A
// {
// void m1();
// }
// interface B
// {
// void m1();
// }
// // class Test implements A,B
// // {
// // public void m1(){}
// // }
// public class Day6_Interfaces implements A,B
// {
// public void m1()
// {
// System.out.println("same implementation");
// }
// public static void main(String[] args)
// {
// }
// }
//----------------------------------------------------
// interface A
// {
// void m1();
// }
// interface B
// {
// void m1();
// }
// class Test1 implements A
// {
// public void m1()
// {
// System.out.println("A");
// }
// }
// class Test2 implements B
// {
// public void m1()
// {
// System.out.println("B");
// }
// }
// public class Day6_Interfaces
// {
// public static void main(String[] args)
// {
// Test1 t1 = new Test1();
// t1.m1();
// Test2 t2 = new Test2();
// t2.m1();
// }
// }
// --------------------------------------------------------------------------------------
// 8.Nested Interfaces
// 1. interface inside class
// 2.interface inside another interface
// class Pavan
// {
// interface Anna
// {
// void m1();
// }
// }
// class Test implements Pavan.Anna
// {
// public void m1()
// {
// System.out.println("M1");
// }
// }
// public class Day6_Interfaces
// {
// public static void main(String arhs[])
// {
// Test t1 = new Test();
// t1.m1();
// }
// }
// --------------------
interface Pavan
{
interface Anna
{
void m1();
}
}
class Test implements Pavan.Anna
{
public void m1()
{
System.out.println("M11111111111111");
}
}
public class Day6_Interfaces
{
public static void main(String arhs[])
{
Test t1 = new Test();
t1.m1();
}
}