-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path69_Inheritance3.java
More file actions
58 lines (54 loc) · 1.04 KB
/
69_Inheritance3.java
File metadata and controls
58 lines (54 loc) · 1.04 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
/*
* Program for Multilevel Inheritance using static value
*/
package javaprograms;
/**
*
* @author Geeky Keshav
*/
public class Inheritance3
{
static int num1;
static int num2;
int sum;
int sub;
int mull;
void sum()
{
sum=num1+num1;
System.out.println("Sum of these numbers: "+sum);
}
}
class child2 extends Inheritance3
{
void sub()
{
sub=num1-num2;
System.out.println("Subtraction of these numbers: "+sub);
}
}
class child3 extends child2
{
void mul()
{
mull=num1*num2;
System.out.println("Multiplication of these numbers: "+mull);
}
}
class child4 extends child3
{
public static void main(String [] args)
{
num1=30;
num2=25;
child4 obj=new child4();
obj.sum();
obj.sub();
obj.mul();
}
}
/********OUTPUT******
Sum of these numbers: 60
Subtraction of these numbers: 5
Multiplication of these numbers: 750
*/