What is the difference between this() and super()?
Answer Posted / puneet khanna
this is used to either call another constructor of the same
class whose object is used to call a method; or whose
constructor is being used to instantiate a class.
This refers to the current object whose reference variable
is used to call method or this refers to the current object
in action,
Super refers to the immediate super class, super(); is
itself placed in the constructor of the class whose super
class doesnt has a constructor declared;for consructor
chaining mechanism.
| Is This Answer Correct ? | 4 Yes | 5 No |
Post New Answer View All Answers
Which are the two subclasses under exception class?
What is the difference between scrollbar and scrollpane?
How can we find the actual size of an object on the heap?
What is encapsulation in java?
Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)
What is meant by inheritance and what are its advantages?
Is java 1.7 the same as java 7?
Is a case study a method or methodology?
How to perform selection sort in java?
When is finally block not called?
What is meant by interface?
Can I learn java without any programming experience?
What is anonymous inner class?
What is the common usage of serialization? What exceptions occur during serialization?
Can we cast any other type to boolean type with type casting?