-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinheritance.java
48 lines (42 loc) · 915 Bytes
/
inheritance.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
import java.util.Scanner;
class calc{
int z;
void add(int x,int y)
{
z=x+y;
System.out.println("the addition of 2 number is = "+z);
}
void sub(int x,int y)
{
z=x-y;
System.out.println("the subtraction of 2 number is = "+z);
}
}
class my_calc extends calc{
void mul(int x,int y)
{
z=x*y;
System.out.println("the Multiplication of 2 number is = "+z);
}
void div(int x,int y)
{
z=x/y;
System.out.println("the division of 2 number is = "+z);
}
}
public class inheritance{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
my_calc ob1 = new my_calc();
int a,b;
System.out.println("enter the first number = ");
a = sc.nextInt();
System.out.println("enter the first number = ");
b = sc.nextInt();
ob1.add(a,b);
ob1.sub(a,b);
ob1.mul(a,b);
ob1.div(a,b);
}
}
ujiiii5