public class Student
{
public String name;
public int age;
public Student()
{
this("David", 45);
}
public Student(String name)
{
this(name, 45);
}
public Student(String name, int age)
{
this.name = name;
this.age = age;
}
}
StudentTest.java public class StudentTest
{
public static void main(String[] args) throws InterruptedException
{
Student student1 = new Student();
System.out.println("name : " + student1.name);
System.out.println("age : " + student1.age);
System.out.println("-----------------------------");
Student student2 = new Student("John");
System.out.println("name : " + student2.name);
System.out.println("age : " + student2.age);
}
}