class Student3{
private int rollNumber;
private String name;
public Student3() {
System.out.println(“Inside Default Constructor”);
rollNumber=0;
name=””;
}
public Student3(int rollNumber,String name) {
System.out.println(“Inside Overloaded Constructor”);
this.rollNumber=rollNumber;
this.name=name;
}
public void displayStudent() {
System.out.println(“rollno= “+rollNumber+”name “+name);
}
}
class ConstructorOverLoad{
public static void main(String arg[])
{
Student3 s1=new Student3(101,”jack”);
s1.displayStudent();
Student s2=new Student();
s2.displayStudent();
}
}
Result:
Inside Overloaded Constructor
rollno= 101name jack
Inside Default Constructor
rollno= 0 name