THIS Keyword in Java / Interview questions on "This" Keyword

THIS Keyword in Java (Rules)

  • Ø  This must be the first statement if we use this in constructor.

    Ø  This can be used to refer current class instance variable (Data shadowing).

    Ø  This keyword can be used to invoke current class constructor.

    Ø  Use this keyword we can achieve constructor chaining.

    Ø  We can print the value of This keyword using println function which return the value of current class instance.

 

Post a Comment