JAVA PROGRAM TO CREATE AN INTERFACE OF DATA RECORD

PROGRAM CODE---

//create an interface of MyData

interface MyRecord
{
void getvalues();
void showvalues();

}

//employee,salary and attendance  class implements MyRecord interface

class Employee implements MyRecord
{
String emp1,emp2;
public void getvalues()
{
emp1="raj";
emp2="suraj";
}

public void showvalues()
{
System.out.println("Employee name is: "+" "+emp1);
System.out.println("Employee name is: "+" "+emp2);
}
}
class Salary implements MyRecord
{
double sal1,sal2;
public void getvalues()
{
sal1=20000;
sal2=45000;
}

public void showvalues()
{
System.out.println("Salary of first employee is : "+" "+sal1);
System.out.println("Salary of second employee is :"+" "+sal2);
}

}
class Attendance implements MyRecord
{
int a1, a2;
public void getvalues()
{
a1=28;
a2=20;
}
public void showvalues()
{
System.out.println("Attendance of first employee is  :"+" "+a1);
System.out.println("Attendance of second employee is :"+" "+a2);
}
}
class CallAll
{
public static void main(String ar[])
{
Employee e=new Employee();
Salary s=new Salary();
Attendance a = new Attendance();
e.getvalues();
s.getvalues();
a.getvalues();
e.showvalues();
s.showvalues();
a.showvalues();
}
}




 OUTPUT OF ABOVE PROGRAM---


Comments