forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingle_Inherit.java
More file actions
54 lines (42 loc) · 725 Bytes
/
Single_Inherit.java
File metadata and controls
54 lines (42 loc) · 725 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
47
48
49
50
51
52
53
54
package oops;
import java.util.Scanner;
public class Single_Inherit {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Der d = new Der();
d.mul();
d.disp_mul();
}
}
class Bas {
private int a;
protected int b;
public void get_ab() {
System.out.println("Enter the value of A and B :");
Scanner s = new Scanner(System.in);
a = s.nextInt();
b = s.nextInt();
s.close();
}
int get_a() {
return a;
}
void show_a() {
System.out.println("A = " + a);
}
}
class Der extends Bas {
int c;
void mul() {
get_ab();
c = get_a() * b;
}
void disp_mul() {
show_a();
System.out.println("B = " + b);
System.out.println("C = " + c);
}
}