-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path68_Inheritance2.java
More file actions
50 lines (46 loc) · 1.1 KB
/
68_Inheritance2.java
File metadata and controls
50 lines (46 loc) · 1.1 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
/*
* Program of Single Inheritance taking input from user
*/
package javaprograms;
import java.io.*;
/**
*
* @author Geeky Keshav
*/
public class Inheritance2
{
static int num1;
static int num2;
int total;
int mull;
void disp()
{
total=num1+num2;
System.out.println("Sum of these numbers: "+total);
}
}
class child1 extends Inheritance2
{
void mul()
{
mull=num1*num2;
System.out.println("Multiplication of these numbers: "+mull);
}
public static void main(String [] args)throws Exception
{
DataInputStream obj1=new DataInputStream(System.in);
System.out.print("Enter first number: ");
num1=Integer.parseInt(obj1.readLine());
System.out.print("Enter second number: ");
num2=Integer.parseInt(obj1.readLine());
child1 obj=new child1();
obj.disp();
obj.mul();
}
}
/*********OUTPUT********
Enter first number: 50
Enter second number: 30
Sum of these numbers: 80
Multiplication of these numbers: 1500
*/