-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathThis_Check.java
More file actions
43 lines (37 loc) · 845 Bytes
/
Copy pathThis_Check.java
File metadata and controls
43 lines (37 loc) · 845 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
package com;
public class This_Check {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//ThisDemo t = new ThisDemo(14,10,4);
new ThisDemo(14,10,4).display();
new ThisDemo(10,4).show();
}
}
class ThisDemo
{
int i,j,k;
ThisDemo(int i , int j , int k) //we can't plug private access specifier t oconstructor because it will be use i nmain method
{
/*i = i; it will not understand by the compiler that
L.H.S is class(instance) variable and R.H.S is local variable*/
this.i = i; //it prevent instance hiding
this.j = j;
this.k = k;
}
ThisDemo(int j, int k)
{
this.j = j;
this.k = k;
}
void display()
{
System.out.println("Addition of all three variables= "+(i+j+k));
}
void show()
{
System.out.println("Multiplication = "+(j*k));
}
}