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

What is the advantage of preparedstatement over statement?

681


What are filterstreams?

695


How can we find the actual size of an object on the heap?

927


What is variable length arguments in java?

616


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

645






What is the list interface in java programming?

666


Why array is used in java?

598


How to do a true java ping from windows?

697


What is main method?

633


State the main difference between c++ and java?

658


How many inner classes can a class have?

668


What is meant by method?

653


Can a constructor be private and how are this() and super() method used with constructor?

625


What is the purpose of tostring() method in java?

647


What does 0 mean in boolean?

626