-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_27_Multiple_inheritance.java
More file actions
60 lines (55 loc) · 1.45 KB
/
Copy path_27_Multiple_inheritance.java
File metadata and controls
60 lines (55 loc) · 1.45 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
// multiple inheritance using interface
// because interface contains only abstract methord , which impliments is provided by the sub classes.
// we can not use this class c extends a,b . we can use class c implements a,b.
//class A{
// void show(){
// System.out.println("This is class A");
// }
//}
//class B{
// void show(){
// System.out.println("This is class B");
// }
//}
//class Multiple extends A,B // error
//{
// public static void main(String[] args) {
// Multiple m = new Multiple();
// m.show();
// }
//}
//interface A{
// void show();
//}
//interface B{
// void show();
//}
//class Multiple implements A,B // error
//{
// public void show(){ // default is week than public thats why we use public.
// System.out.println("Interface A & B");
// }
// public static void main(String[] args) {
// Multiple m = new Multiple();
// m.show();
// }
//}
interface A{
void Show();
}
interface B{
void Disp();
}
class Multiple implements A,B
{
public void Show(){ // default is week than public thats why we use public .
System.out.println("Interface A ");
}
public void Disp(){ // default is week than public thats why we use public .
System.out.println("Interface B");
}
public static void main(String[] args) {
Multiple m = new Multiple();
m.Show(); m.Disp();
}
}