-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultilevel.java
48 lines (48 loc) · 992 Bytes
/
Multilevel.java
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
// Multi-Level Inheritance
class A // Super class
{
int a,b,c;
void Add()
{
a=10; b=20;
c=a+b;
System.out.println(" Sum of Two nos "+c);
}
void Sub()
{
a=100; b=20;
c=a-b;
System.out.println(" Substraction of Two nos "+c);
}
}
class B extends A // sub1 class
{
void multi()
{
a=20; b=30;
c=a*b;
System.out.println(" Multiplication of Two nos "+c);
}
void divi()
{
a=100; b=50;
c=a/b;
System.out.println(" Division of Two nos "+c);
}
}
class Multilevel extends B //sub2 class
{
void rem()
{ a=20; b=3;
c=a%b;
System.out.println(" Remainder of Two nos "+c);
}
public static void main(String[] args) {
Multilevel r=new Multilevel();
r.Add();
r.Sub();
r.multi();
r.divi();
r.rem();
}
}