-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceInheritence.java
More file actions
65 lines (50 loc) · 962 Bytes
/
Copy pathInterfaceInheritence.java
File metadata and controls
65 lines (50 loc) · 962 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package t1;
interface I2
{
void f1();
void f5();
}
interface I3
{
void f2();
void f5();//ambiguity (i.e. child has more than one parent)
//ambiguity is removed because two function has same function name but there are no body
}
interface I4 extends I2,I3//Multiple inheritance can only occur in interface
{
void f3();
}
class All implements I4
{
/* We must have to over ride all the function of interface to avoid error
* We must have to write public before the over riding function
* */
public void f1()//Must write public
{
System.out.println("F1");
}
public void f2()
{
System.out.println("F2");
}
public void f3()
{
System.out.println("F3");
}
public void f5()
{
System.out.println("F5");
}
}
public class InterfaceInheritence
{
public static void main(String[] args)
{
//I1 i = new I1();//We can't create object of a interface
All ob1 = new All();
ob1.f1();
ob1.f2();
ob1.f3();
ob1.f5();
}
}