public class Pupil {
int rollNo;
String name;
int age;
Pupil(int r, String s, int a) {
rollNo = r;
name = s;
age = a;
}
Pupil(Pupil p) {
rollNo = p.rollNo;
name = p.name;
age = p.age;
}
void display() {
System.out.println("Roll no of student is :" + rollNo);
System.out.println("Name of student is :" + name);
System.out.println("Age of student is :" + age);
}
public static void main(String args[]) {
Pupil p1 = new Pupil(123, "Sudeep", 25);
Pupil p2 = new Pupil(p1);
System.out.println("---------------------------------------------------");
System.out.println("Details of First Student");
p1.display();
System.out.println("---------------------------------------------------");
System.out.println("Details of Second Student copied from first Student");
p2.display();
System.out.println("---------------------------------------------------");
}
}