-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.java
49 lines (46 loc) · 947 Bytes
/
test.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
49
import java.util.Scanner;
class a{
int z;
a()
{
System.out.println("hello i am the base class constructor");
}
void add(int x,int y){
z = x+y;
System.out.println("the addition of 2 numbers is = "+z);
}
void sub(int x,int y){
z = x-y;
System.out.println("the subtraction of 2 numbers is = "+z);
}
}
class b extends a{
b()
{
System.out.println("hello i am the derived class constructor");
}
void mul(int x,int y){
z = x*y;
System.out.println("the addition of 2 numbers is = "+z);
}
void div(int x,int y){
z = x/y;
System.out.println("the subtraction of 2 numbers is = "+z);
}
}
class test{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int a,e;
System.out.println("enter the value of a = ");
a = sc.nextInt();
System.out.println("enter the value of a = ");
e = sc.nextInt();
b ob1 = new b();
ob1.add(a,e);
ob1.sub(a,e);
ob1.mul(a,e);
ob1.div(a,e);
}
}