What is the usage of this keyword in java?

Questions by yuthan

Showing Answers 1 - 7 of 7 Answers

vijaya sagar

  • May 5th, 2006
 

Keyword are reserved words in Java. They have a special meaning and they cannot be used as a names of the variables. For eg. float is a resereved word which tells the compiler that a particular variable is of type float and allocat the necessary amount of memory for float

  Was this answer useful?  Yes

yuthan

  • May 9th, 2006
 

Thank u Sridhar.

  Was this answer useful?  Yes

abc

  • May 11th, 2006
 

this is used to refer to the current object of the class

  Was this answer useful?  Yes

Vijayabalan

  • May 12th, 2006
 

Dear Vijaya Sagar,

                       Thank you for your answer for my question. Can you able to tell the difference between an inheritance and an abstract class.

Regards,

VIJAYABALAN.G

  Was this answer useful?  Yes

ashwinsware

  • May 22nd, 2006
 

Hi Friends,

             The this keyword in java has two uses

  • It is used to get the current object that is the object on which the current method is called. To avoid data corruption in complicated programmes u can send the current object using this keyword to any method.
  • The this keyword is also used for constructor chainning. In case of overloaded constructors, u can call other constructors using this keyword. it should be the first statement in the constructor if called(esle super).

                                                  Thank u,

                                            Ashwin Pimpale.

  Was this answer useful?  Yes

suman

  • Jun 13th, 2006
 

 I would like to give you an explanation of using this(). Suppose we have class A having method1(), class B extends A having method1().IN lass B we need to call method1() of classB.if we call it as usually as we do(method1()) compiler does not understand which method1() should me called.so, in order to remove the convention we use the key word this() to call the method1() of Class B. If we wann to call method1() of ClassA ten we use the key word super().

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions