public class Pupil1 {
int rollNo;
String name;
int age;
Pupil1(int r, String s, int a) {
rollNo = r;
name = s;
age = a;
}
Pupil1(){}
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[]) {
Pupil1 p1 = new Pupil1(123, "Sudeep", 25);
Pupil1 p2 = new Pupil1();
p2.rollNo = p1.rollNo;
p2.name = p1.name;
p2.age = p1.age;
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");
System.out.println()
p2.display();
System.out.println("---------------------------------------------------");
}
}