Sitemap

Member-only story

What Is Constructor Overloading in Java? (Java Interview QA)

Learn what constructor overloading is in Java, why it’s useful, and how to implement it with real-world examples and simple explanations.

2 min readApr 2, 2025

📌 Definition

Constructor overloading in Java means creating multiple constructors in the same class, each with different parameter lists.

➡️ It allows you to create objects in multiple ways depending on what data is available.

🧱 Basic Syntax

public class Book {
String title;
String author;

// Constructor 1
public Book() {
this.title = "Unknown";
this.author = "Unknown";
}

// Constructor 2
public Book(String title) {
this.title = title;
this.author = "Unknown";
}

// Constructor 3
public Book(String title, String author) {
this.title = title;
this.author = author;
}
}

🧪 Usage:

Book b1 = new Book();                     // uses constructor 1
Book b2 = new Book("Java in Action"); // uses constructor 2
Book b3 = new Book("Spring Boot", "John"); // uses constructor 3

✅ Each constructor initializes the object differently based on the provided parameters.

Why Use Constructor Overloading?

--

--

No responses yet