Register for our webinar

How to Nail your next Technical Interview

1 hour
Loading...
1
Enter details
2
Select webinar slot
*Invalid First Name
*Invalid Last Name
*Invalid Phone Number
By sharing your contact details, you agree to our privacy policy.
Select your webinar time
Step 1
Step 2
Congratulations!
You have registered for our webinar
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
Step 1
Step 2
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
Iks white logo

You may be missing out on a 66.5% salary hike*

Nick Camilleri

Head of Career Skills Development & Coaching
*Based on past data of successful IK students
Iks white logo
Help us know you better!

How many years of coding experience do you have?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Our June 2021 cohorts are filling up quickly. Join our free webinar to Uplevel your career
close
closeAbout usWhy usInstructorsReviewsCostFAQContactBlogRegister for Webinar

Attend our Free Webinar on How to Nail Your Next Technical Interview

WEBINAR +LIVE Q&A

How To Nail Your Next Tech Interview

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings

Constructor Chaining in Java with Examples

Attend our Free Webinar on How to Nail Your Next Technical Interview

WEBINAR +LIVE Q&A

How To Nail Your Next Tech Interview

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings

Constructor Chaining in Java with Examples

## Introduction Constructor chaining is a process of calling one constructor from another constructor with respect to current object. It is also known as constructor delegation. It is mainly used for code reusability or for code optimization. This process is also known as method chaining. In this article, we will discuss constructor chaining in Java with examples. Constructor chaining is a useful concept in Java, as it allows a class to have more than one constructor that calls the same constructor with different parameters. This process helps in code reusability and optimizes the code. In constructor chaining, the constructors of the same class or its parent class are called. Constructor chaining is generally used to initialize the instance variables of a class. With the help of constructor chaining, object creation becomes faster, as the same constructor is called multiple times. It also helps to reduce the code size and complexity. Constructor chaining is an important concept of object-oriented programming. It helps in code reusability and optimization as the same constructor is called multiple times with different parameters. This helps to reduce code size and complexity. Constructor chaining is used to initialize the instance variables of a class. It is also used to reduce the number of constructors that need to be written. Constructor chaining can be used to call the constructor of the same class or the constructor of the parent class. The constructors in the chain are executed in the same order as they are called. Constructor chaining is an important concept in Java, as it helps in code optimization and reusability. It helps to reduce the number of constructors that need to be written and also helps to initialize the instance variables of a class. Constructor chaining can be used to call the constructor of the same class or the constructor of the parent class. The constructors in the chain are executed in the same order as they are called. In this article, we will discuss constructor chaining in Java with examples.

Worried About Failing Tech Interviews?

Attend our webinar on
"How to nail your next tech interview" and learn

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings
Register for Webinar
Constructor Chaining is the process of calling one constructor from another constructor of the same class or of its parent class. It is used to reuse the code and avoid the redundant code. Syntax: class class_name { // constructor 1 class_name() { // code to be executed } // constructor 2 class_name(parameters) { // code to be executed this(); } } Example: class Rectangle { int length; int breadth; // Default constructor Rectangle() { System.out.println("Constructor Chaining Example"); } // Parameterized constructor Rectangle(int length, int breadth) { this.length = length; this.breadth = breadth; this(); } } public class Test { public static void main(String[] args) { // Creating an object using default constructor Rectangle r1 = new Rectangle(); // Creating an object using parameterized constructor Rectangle r2 = new Rectangle(10, 20); } } Output: Constructor Chaining Example