Difference between this(), super()?

Answers were Sorted based on User's Feedback

Answer / venki

this can be pointing to current object.
super can be used for accesing super class metods &varibles.
'this &super' are use full for constructers also .
thes two statements defining first satatement of
constructer.'this' is used for accesing current class
constuter.where as super is accessing super class

Is This Answer Correct ?    55 Yes 5 No

Answer / janet

this() can be used to invoke a constructor of the same
class where as super() can be used to invoke a super class

Is This Answer Correct ?    53 Yes 6 No

Answer / priyanka das

"super" is a keyword used to invoke superclass data members and also superclass member methods,whereas "this" is a keyword used to invoke the current class data member as well as current class member methods.

A super object can be used to retrieve super class members."this' object can be used to invoke only the current class members.

Again super() can be used to invoke the superclass constructor where as this() can be used to invoke current class constructor.

Is This Answer Correct ?    23 Yes 0 No

Answer / selvan

this & super is a keyword.
"this" is used to invoke a constructor of a same class,
its pointing the same class object.

"super" is used to invoke a superclass constructor and
accessing the superclass constructor.

Is This Answer Correct ?    25 Yes 3 No

Answer / nikhlesh gupta

this() call one of user define constructor inside another user constructor of the same class such as this(a), this(a,b) & so on.
super() call one of base class constructor inside the derive class constructor such as super(a), super(a,b) & so on.

Is This Answer Correct ?    26 Yes 5 No

Answer / a .k. singh

This keyword is pointing the same class object.and
super keyword is accessing the superc lass constructor

Is This Answer Correct ?    10 Yes 2 No

Answer / a.k.singh

your ans no.6 is wrong because (superc lass )constructor
superc lass mence!!!!!!!!!!1

Is This Answer Correct ?    11 Yes 3 No

Answer / ghulam mujtaba

this()can be used invoke to Constructor of the same class
Whereas super() can be used to invoke a super class

Is This Answer Correct ?    10 Yes 4 No

Answer / bindhu solomon

'this' is a pointer points to the object of the methods
invokes. super() is used to invoke the super class member

Is This Answer Correct ?    17 Yes 12 No

Answer / shanthappa

"this" is the implicit keyword/object oriented by the jvm and supplied to every java programs for two purposes.
1) It points to current class object
2) It whenever formal parameters of the class are similar then jvm gets an ambiguity.
"super" is a keyword which will differentiate base class features with derived class features.
The keyword 'super' is placing an important role in three places in java...
1)at variable level
2)at constructor level
3)at method level

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can we have a abstract class withought any method? What is a purspose of this?

3 Answers  

take any 4 input numbers. like 2345.. wanted out put is All 16 combinations of the number 2345.. for example- taking input as 4565 output- 5654 4556 4655..

2 Answers   Emphasis,

Under what circumstances an object reference be cast to an interface reference?

3 Answers  

Scenario: There are 1 to 100 numbers. Each number should be keep in the each column like from A column to Z column ie 1 to 26. From 27 to 52 should be in 2nd row in the excel sheet. This has to be continue till 100. How do you write Java program and what are various methods.

4 Answers   Cap Gemini,

Life Cycle of Thread

4 Answers   IBM,

What is constructor and virtual function?

5 Answers  

What is the Dictionary class?

1 Answers  

If there are two notepad opened and working on it . is this a process or thread? computer based Live Example to differentiate between Thread , Process , and Multi tasking ?

3 Answers   TCS, Wipro,

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what the name should i provide to the file ,in what file name should i run the program? Ple Explain

9 Answers   Infosys, TCS, DNS,

10. class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST } 12. } 13. public class Sprite{ 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile? a)Direction d = NORTH; b)Nav.Direction d = NORTH; c)Direction d = Direction.NORTH; d)Nav.Direction d = Nav.Direction.NORTH;

2 Answers  

explain the clone method and clonable interface

1 Answers  

How the threads are synchronized?

2 Answers   CTS, BMC,