please explain this keyword clearly that where we use this keyword in super and subclass.
This is a reference variable used to refer to the current object of the class. It is used with the constructor and used to refer to the current object of the constructor using this keyword.br /for an example:br /ustrongUSE OF this KEYWORD IN THE PROGRAM BELOW:/strong/ubr /strongclass/strong Student{ br /strongint/strong rollno; br /String name; br /strongfloat/strong fee; br /Student(strongint/strong rollno,String name,strongfloat/strong fee){ br /strongthis/strong.rollno=rollno; br /strongthis/strong.name=name; br /strongthis/strong.fee=fee; br /}br /br /stronguWITHOUT USING this KEYWORD:/ubr /class/strong Student{ br /strongint/strong rollno; br /String name; br /strongfloat/strong fee; br /Student(strongint/strong r,String n,strongfloat/strong f){ br /rollno=r; br /name=n; br /fee=f; br /} br /br /
this keyword is used in constructors In any constructor the first statement is always a super calling or this calling statement super is used to call the super class constructer and this keyword refers to the current constructor
Keyword 'THIS' in Java is a reference variable that refers to the current object. "this" is a reference to the current object, whose method is being called upon. You can use "this" keyword to avoid naming conflicts in the method/constructor of your instance/object
"this" keyword is implicit object created by java environment, "this" keyword is always points to the current class object. when the formal parameters and current class data members are same then JVM get ambiguity problem, then to differentiate between formal parameters and data members of class we must be preceded by "this" keyword. syntax: this.data_member_name
This Keyword is use to represent current class Object. We can use this Member function as well as in constructor . But not in Static Member function. We can use this(),this(10),....; to call construcor of that class but it must be present or declare
strongthis /strongkeyword is use to access the elements of current class
This keyword is used to differenciate the instance variables and local variable. For example: Class swap {int a, b; void swaping(int a,int b){this.a=a;this.b=b;}}
strongKeyword/strong 'THIS' in strongJava/strong is a reference variable that refers to the current object. It can be used to refer current class instance variable. It can be used to invoke or initiate current class constructor.
1. this keyword is used to differentiate between instance and local variable. Ex: this.a=a; Where this.a is a instance variable and a is a constructor variable. 2. this() is used for local chaining in the program.
"this" is a keyword used to refer the current object in java program. it hold the address of current object.When the actual argument and formal argument are same use this key word to differentiate.br /this() call the current class constructor(because it hold the current objct adrs whenever objct is created constructed invoked its was the basic behind the this() method).
We use it with constructors or variables or methods.br /Used to give reference to the variables.
Keyword strong'THIS'/strong in Java is a reference variable that refers to the current object.br /The various usage of keyword Java 'THIS' in Java is as per the below,br /It can be used to refer current class instance variablebr /It can be used to invoke or initiate current class constructorbr /It can be passed as an argument in the method callbr /It can be passed as argument in the constructor callbr /It can be used to return the current class instance
"this" is a implicit object whose pointing to current class object for initilaized current class data member. When we ar going for this.. Suppose I have programmer difined parameterized constructor whose formal parameters name is simillar to class data member. Then JVM will go in confusion which variable are current class variable.. So simply we apply" this" keyword... It generate difference bw current class data member to formal parameter....