.

Friday 27 March 2015

Program to set and print employee details

class Details

int empid,deptid,salary;

//method to set details
void setEmployeeDetails()
{
empid=10002;
deptid=15;
salary=5000;
}

//method to print details
void printEmployeeDetails()
    {
System.out.println(empid);
System.out.println(deptid);
System.out.println(salary);
      }

}

//main class
class employee
{
public static void main(String[] args)
{

//method to create object of detail class

details ob=new details();

//method to call the function through object

ob.printEmployeeDetails();
}
}

No comments:

Post a Comment