-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritanceExp.java
More file actions
46 lines (44 loc) · 989 Bytes
/
InheritanceExp.java
File metadata and controls
46 lines (44 loc) · 989 Bytes
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
import java.util.*;
public class InheritanceExp {
public static void main(String[] args) {
B b = new B();
b.setData();
System.out.println("Max Value:" + b.maxValue());
System.out.println("Min Value:" + b.minValue());
}
}
class A{
private int i, j;
public void setData(){
Scanner inp = new Scanner(System.in);
System.out.print("Enter the Value of i and j\n:");
i = inp.nextInt();
System.out.print(":");
j = inp.nextInt();
}
public int getDataI(){
return i;
}
public int getDataJ(){
return j;
}
}
class B extends A{
int i, j;
int maxValue(){
i = getDataI();
j = getDataJ();
if(i>j)
return i;
else
return j;
}
int minValue(){
i = getDataI();
j = getDataJ();
if(i<j)
return i;
else
return j;
}
}