How are this() and super() used with constructors?

Answer Posted / sushila sonare

When we create an object, first constructor called. In a
constructor first statement should be either this() or
super(). If we didn't keep anything compiler kept super()
statement so constructor chain will be completed. Control
goes to Object class constructor and object creation will
completed. Suppose this() statement kept in constructor than
current class suitable constructor called and this chain
will be continue until control goes to Object class
constructor.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to sort a collection of custom Objects in Java?

585


Why is string class considered immutable?

587


What do you mean by Hash Map and Hash Table?

590


Define a package.

557


What is application tier?

517






Can I import same package/class twice?

480


What is generic class?

635


What is meant by main method?

566


What methods are used to get and set the text label displayed by a button object?

540


How can constructor chaining be done using this keyword?

576


What is update method called?

649


we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.

1550


How many types of constructors are used in java?

527


Is 0 an even number?

531


Is java a utf 8 string?

516