"A java program to demonstrate the use of "
class ThisDemo1
{
int a = 0;
int b = 0;
ThisDemo1(int x, int y)
{
this.a = x;
this.b = y;
}
public static void main(String [] args)
{
ThisDemo1 td = new ThisDemo1(10,12);
ThisDemo1 td1 = new ThisDemo1(100,23);
System.out.println(td.a); // prints 10
System.out.println(td.B); // prints 12
System.out.println(td1.a);// prints 100
System.out.println(td1.B);// prints 23
}
}
when we compile and run the program we get the output as:-
C:\Java\Concepts\DeclarationAndAccessControl>java ThisDemo1
10
12
100
23
10
12
100
23
-------------------------------------------------------------------------------------------------
No comments:
Post a Comment