Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between Super and This Keyword?

Answer Posted / deep

Super and This both are keywords and which has some predefined meaning..

Super - with the help of super, you could call super class constructor, method and member of super class..

This - it's used to avoid instance variable hiding, when local variable and instance variable has same name, then at time of assignment, local variable hides instance variable, so in order to get over this problem, this is used to refer instance variable..

class A {
int x; // instance variable
public void m(int x) {
x = x; // here local variable x hides instance variable
x.. so better use this to refer the instance variable

this.x = x; here this.x refer to instance variable and where another x is local variable
}

this is also used to call current class constructor and it can also used to pass current class constructor or method to another object..

you can also use this to call current class constructor or methods..

Rule: Call to this() must be the first statement in constructor or else it will result in compile time error..

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?

996


What is the difference between system.out ,system.err and system.in?

1047


What is in-memory replication?

1009


What class is used to create Server side object ?

2174


How are the elements of a borderlayout organized?

1048


which type of objects reference will be given to client?

2432


How is a java object message delivered to a non-java client?

994


What is the relationship between the canvas class and the graphics class?

982


What is the difference between the string and stringbuffer classes?

1034


What is the highest-level event class of the event-delegation model?

1032


hi friends, i have done my BE(CSE)at 2011 then i have joined one company before they asked me 50k so i paid but now they telling no project here so we r going to close like that so now i need any job i have good knowledge in core java and j2ee(jsp,servlet,jdbc) so if u know any job pl help me

2160


What is the form of storage space in java?

2197


what is Activation Instantinator?

2368


Explain what is orm?

1066


What is the purpose of the finally clause of a try-catch-finally statement?

981