How are this and super used?

Answers were Sorted based on User's Feedback

Answer / sucharitha

this() is used to invoke present class constructor.Super()
is used to invoke super class Constructor.

Is This Answer Correct ?    8 Yes 0 No

Answer / niranjanravi

this is used to resolve the naming collision between class
scope var. and method scpoe var.
super is used to the resolve the naming collision between
superclass member and subclass member.

Is This Answer Correct ?    6 Yes 0 No

Answer / ravikiran(aptech mumbai)

this keyword is used to refer the current instance of the
particular class where as super keyword is used to refer the
superclass members.

Is This Answer Correct ?    5 Yes 0 No

Answer / kabita

'this' and super are two keywords in java.
'this' doesn't support inheritance bt 'super' supports
this keyword is used in two cases differentiate betn instance and local variables.
2.calling of one constructor from another constructor.
Restriction:this keyword should be written in lowercase &
must used in firstline.more than one 'this' keyword is not
used in one block.
super is used 4 three reason.
1.differentiates betn superclass variable & child class
2.calling of superclass constructor in childclass
constructor. is also used in calling of superclass override method
in child class.
it must be in 1stline.
must be in lowercase.

Is This Answer Correct ?    4 Yes 0 No

Answer / shripal

this() keyword is use to invoke the current class.
while super() keyword is use to invoke super class.

Is This Answer Correct ?    2 Yes 0 No

Answer / sreekar reddy vanguru

Mainly this() is used to avoid hidding the field varaibles
by the varaibles of the methods which are having same name..

super() is used to invoke the super class from sub class...

Is This Answer Correct ?    0 Yes 0 No

Answer / qim2010

this() is used to invoke a constructor of the same class

super() is used to invoke a super class constructor and

Example of using this():
public Pet(int id) { = id; // “this” means this object
public Pet (int id, String type) {
this(id); // calls constructor public Pet(int id)
this.type = type; // ”this” means this object

Example of using super():

If a class called “SpecialPet” extends your “Pet” class then
you can
use the keyword “super” to invoke the superclass’s
constructor. E.g.
public SpecialPet(int id) {
super(id); //must be the very first statement in the

To call a regular method in the super class use:
“super.myMethod( );”. This can be called at any line.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

what is domain object

1 Answers  

What is access modifiers?

1 Answers   Cap Gemini,

"We cannot create an object of interface but we can create a variable of it". Discuss the statement with the help of an example. (Plz help us to provide immediately.)

3 Answers  

Hi Friends, I am new to java. Can u explain about thread concept.How i know one thread is locked, and how can i force or acquire another thread for lock . Finally how to know thread is released from lock. Explain types of lock(like method level and block level) in thread.

1 Answers  

Tell me the Importent classes in net package?

0 Answers  

what happens when we add the objects morethan the size limit to a hashmap

1 Answers  

My interview asked what is dynamic variable in java and where we use them.

2 Answers   IBM,

waht You know about thread programming?

1 Answers  

watz the difference between abstract class and interface? Which one u ill choose as a designer?

1 Answers   Sonata,

where is .equals() method and how is it different from == operation <giving some confusing implementation> Is hashing related to these?

4 Answers   iFlex,

What advantage does an entity bean have over a sessin bean?

3 Answers   Adobe,

Hi am an mca graduate . i have done bsc maths in my degree . every company asks me why you make shift from maths group to computere field . What i need to answer?

2 Answers