class Main
{
JAVA 3rd SEM 4
public static void main(String[] args)
{
staff obj[] = new staff[3];
obj[0] = new teaching("John", 101, 50000.0f, 1375, "p
rofessor", "security");
obj[1] = new technical("John", 101, 50000.0f, 1375,
"vscode");
obj[2] = new contract("John", 101, 50000.0f, 1375, 22
4);
System.out.println("Name\tstaff_id\tphone\tsalary\tdomain
\t\tpublications\tskills\t\tperiod");
for (int i = 0; i < 3; i++)
{
obj[i].display();
}
}
}
class staff
{
String name;
int staff_id;
long phone;
float salary;
public staff(String name, int staff_id, float salary,
long phone)
{
this.name = name;
this.staff_id = staff_id;
this.phone = phone;
this.salary = salary;
}
void display()
JAVA 3rd SEM 5
{
System.out.print(name + "\t" + staff_id + "\t\t" + phone
+ "\t" + salary);
}
}
class teaching extends staff
{
String domain, publications;
public teaching (String name, int staff_id, float sal
ary, long phone, String domain, String publications)
{
super(name, staff_id, salary, phone);
this.domain = domain;
this.publications = publications;
}
void display()
{
super.display();
System.out.println("\t" + domain + "\t" + publica
tions + "\t\t");
}
}
class technical extends staff
{
String skills;
public technical(String name, int staff_id, float sal
ary, long phone, String skills)
{
super(name, staff_id, salary, phone);
this.skills = skills;
}
JAVA 3rd SEM 6
void display()
{
super.display();
System.out.println("\t\t\t" + "\t\t" +skills +
"\t\t");
}
}
class contract extends staff
{
int period;
public contract(String name, int staff_id, float salary,
long phone, int period)
{
super(name, staff_id, salary, phone);
this.period = period;
}
void display()
{
super.display();
System.out.println("\t\t\t\t\t\t\t" + period);
}
}