Java67 - Java Program Example Tutorial Blog |
How Constructor Chaining works in Java - Example Posted: 31 Dec 2012 05:07 AM PST How to call one constructor from other constructor in Java or What is Constructor Chaining in Java is one of the tricky questions in Java interviews. Well you can use this keyword to call one constructor from other constructor of same class, if you want to call constructor from based class or super class than you can use super keyword. Calling one constructor from other is called Constructor chaining in Java. Constructors can call each other automatically or explicitly using this() and super() keywords. this() denotes a no argument constructor of same class and super() denotes a no argument or default constructor of parent class. Also having multiple constructor in same class is known as constructor overloading in Java. |
You are subscribed to email updates from Java67 - Java Program Example Tutorial Blog To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Post a Comment