AJIT KUMAR BTECH - 15163 - 19 OPD Lab Assignment-7
AJIT KUMAR BTECH - 15163 - 19 OPD Lab Assignment-7
Lab
Assignment 7
if (randomNum == 1)
compartments[i] = new FirstClass();
else if (randomNum == 2)
compartments[i] = new Ladies();
else if (randomNum == 3)
compartments[i] = new General();
else if (randomNum == 4)
compartments[i] = new Luggage();
compartments[i].notice();
}
}
}
Output:
2. Write a program in java which implement interface Student which has two
methods Display_Grade and Attendance for PG_Students and UG_Students
(PG_Students and UG_Students are two different classes for Post Graduate
and Under Graduate Students respectively).
interface Student {
void Display_Grade();
void Display_Atten();
}
void Display() {
System.out.println("Name is " + name);
System.out.println("Marks are " + m1 + " " + m2 + " " +
m3);
}
void Display() {
System.out.println("Name is " + name);
System.out.println("Marks are " + m1 + " " + m2 + " " +
m3);
}
Output: