-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.java
More file actions
29 lines (24 loc) · 678 Bytes
/
C.java
File metadata and controls
29 lines (24 loc) · 678 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
// Rejection of multiple Inheritance in java.
class A{
void msg() {
System.out.println("A");
}
}
class B{
void say() {
System.out.println("B");
}
}
public class C extends A, B { // Suppose if it were.
public static void main(String[] args) {
// TODO Auto-generated method stub
C c = new C();
c.msg(); // Now which msg() method would be invoked.
}
/*
* Important Note: The above code won't run. It will show an Compilation Error.
* The reason of this error is Java does not support multiple inheritance.
* The reason to avoid multiple inheritance is to reduce the complexity and simplify the language.
*
*/
}