-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinheritance.java
More file actions
34 lines (33 loc) · 988 Bytes
/
inheritance.java
File metadata and controls
34 lines (33 loc) · 988 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
package inheritance;
// driver class for the demonstration of various types of inheritance in java.
public class inheritance {
public static void main(String[] args) {
// single inheritance
System.out.println("single inheritance: ");
Singleparent sp = new Singleparent();
sp.add();
Singlechild sc = new Singlechild();
sc.multiply();
sc.add();
// multilevel inheritance
System.out.println("multilevel inheritance: ");
Multiparent mp = new Multiparent();
mp.display();
Multiintermediate mi = new Multiintermediate();
mi.display();
mi.displaySum();
Multichild mc = new Multichild();
mc.display();
mc.displaySum();
mc.displayTripleSum();
// hierarchial inheritance
System.out.println("hierarchial inheritance: ");
HierarchialParent hp = new HierarchialParent();
hp.sum(5, 7);
hp.sub(7, 5);
HierarchialChildOne hco = new HierarchialChildOne();
hco.displaySum();
HierarchialChildTwo hct = new HierarchialChildTwo();
hct.displaySub();
}
}