August 22, 2009 at 4:24 PM
Output of this program is:
Three integer variables(a,b,c) and three methods have been defined in ThisDemo.java class.
The method show() of void type contains three parameters a,b,c.Through 'this' keyword,you can refer to any member of the current object from within an instance method. In this method, this.a is used to refer to the class field a.This value is then passed to the method variable 'a'by using this.a=a.When show() method is called with the values(2,2,2),it will display the values of b and c 0 as this keyword is not used to refer the class variables b and c.
The method show() with single parameter makes the values of class variable a,b and c equal by equalizing all the class fields with its variable.When this method is called with parameter value 3, it will display the product of three numbers i.e, 3*3*3=27.
The method volume() returns the product of three variables.When this method is called,it takes the value 2,3,3 of a,b,c respectively and shows the volume 18.