-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path70_Inheritance4.java
More file actions
68 lines (60 loc) · 1.37 KB
/
70_Inheritance4.java
File metadata and controls
68 lines (60 loc) · 1.37 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
61
62
63
64
65
66
67
68
/*
* Program for Multilevel Inheritance taking input from user
*/
package javaprograms;
import java.io.*;
/**
*
* @author Geeky Keshav
*/
public class Inheritance4
{
static int num1;
static int num2;
int sum;
int sub;
int mul;
void sum()
{
sum=num1+num2;
System.out.println("Sum of these numbers: "+sum);
}
}
class first extends Inheritance4
{
void sub()
{
sub=num1-num2;
System.out.println("Subtraction of these numbers: "+sub);
}
}
class second extends first
{
void mull()
{
mul=num1*num2;
System.out.println("Multiplication of these numbers: "+mul);
}
}
class third extends second
{
public static void main(String [] args)throws Exception
{
DataInputStream obj=new DataInputStream(System.in);
System.out.print("Enter first number: ");
num1=Integer.parseInt(obj.readLine());
System.out.print("Enter second number: ");
num2=Integer.parseInt(obj.readLine());
third obj1=new third();
obj1.sum();
obj1.sub();
obj1.mull();
}
}
/******OUTPUT*****
Enter first number: 50
Enter second number: 60
Sum of these numbers: 110
Subtraction of these numbers: -10
Multiplication of these numbers: 3000
*/