-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUseThis.java
More file actions
35 lines (31 loc) · 784 Bytes
/
UseThis.java
File metadata and controls
35 lines (31 loc) · 784 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
//Auhtor : Deepansh Dubey.
//Date : 21/09/2021.
import java.io.*;
class UseThis
{
int a,b,sum;
UseThis()
{
a=50;
b=100;
sum=a+b;
System.out.println("Sum by constructor = "+ sum);
}
void add(int a,int b)
{
this.a=a;
this.b=b;
this.sum=this.a+this.b;
System.out.println("Sum by method = " + sum);
}
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
int x,y;
System.out.println("Please enter the \nx:\n&\ny:");
x=Integer.parseInt(br.readLine());
y=Integer.parseInt(br.readLine());
UseThis ob=new UseThis();
ob.add(x,y);
}
}