-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.java
More file actions
56 lines (41 loc) · 1.09 KB
/
Copy pathinheritance.java
File metadata and controls
56 lines (41 loc) · 1.09 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
class calc
{
protected int func = 10;
public int add(int a, int b)
{
System.out.println(func);
return a+b;
}
public int sub(int a, int b)
{
return a-b;
}
}
public class inheritance
{
public static void main(String[] args)
{
calc c = new calc();
//c.func; --private var.
System.out.println(c.func);
calc c1 = new calc();
int a = c1.add(5,7);
int b = c1.sub(10,6);
System.out.println(a + " " + b);
advcalc a1 = new advcalc();
//nt c = a1.multi(3,4);
int d = a1.div(15,4);
System.out.println(c + " " + d);
advcalc a2 = new advcalc();
int e = a2.add(3, 8);
int f = a2.sub(7, 4);
System.out.println(e + " " + f);
veryadvcalc v1 = new veryadvcalc();
double g = v1.exp(2, 4);
int h = v1.add(5, 6);
int i = v1.sub(7 , 3);
int j = v1.multi(3, 5);
int k = v1.div(10, 5);
System.out.println(g + " " + h + " " + " " + i + " " + j + " " + k);
}
}