Constructor overloading means defining multiple constructors in the same class, each with a different parameter list:
class Student {
String name;
int grade;
Student(String name, int grade) {
this.name = name;
this.grade = grade;
}
Student(String name) {
this.name = name;
this.grade = 1;
}
}
Now you can write new Student("Alice", 10) or new Student("Bob"). Java picks the constructor that matches the arguments you pass. The second constructor assigns a default grade of 1.
You can also call one constructor from another using this(). This avoids duplicating setup code across constructors.