-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterError.java
More file actions
40 lines (33 loc) · 903 Bytes
/
InterError.java
File metadata and controls
40 lines (33 loc) · 903 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
interface Alpha{
default void meth(){
System.out.println("Inside Alpha");
}
}
interface Beta{
default void meth(){
System.out.println("Inside Beta");
}
}
class InterErr implements Alpha, Beta{
void OwnMeth(){
System.out.println("Class specific method");
}
//after overriding the methods, error wont occure in the program.
public void meth(){
System.out.println("Methods of Alpha and Beta are overridden");
}
}
class MainClass{
public static void main(String ...args){
/**
the below code will result in an error because both the interfaces
have same default method signature and hence, would result in an
ambiguity/conflict.
InterErr ob = new InterErr();
ob.meth();
To resiove such a situation, the class implementing the interfaces must override the methods.
*/
InterErr ob = new InterErr();
ob.meth();
}
}