Saturday, 17 August 2013

Employee using Java

employee.java
-------------------

class employee
{
public static void main(String args[]){
emp a1=new emp("Asif",20,"CST");
emp a2=new emp("Musa",21);
emp a3=new emp("Ani");
a1.show_details();
a2.show_details();
a3.show_details();
a1.show_name();
a2.show_name();
a3.show_name();
}
}

class emp
{
String e_name,e_dept;
int e_age;
emp(){ };
emp(String name){
this.e_name=name;
this.e_age=18;
this.e_dept="CST";
}
emp(String name,int age){
this.e_name=name;
this.e_age=age;
this.e_dept="CST";
}
emp(String name,int age, String dept){
this.e_name=name;
this.e_age=age;
this.e_dept=dept;
}
void show_details(){
System.out.println("\nName:"+e_name);
System.out.println("\nAge:"+e_age);
System.out.println("\nDepertment:"+e_dept+"\n");
}
void show_name(){
System.out.println("\nName:"+e_name);
}
}

Output:
------------

Name:Asif

Age:20

Depertment:CST


Name:Musa

Age:21

Depertment:CST


Name:Ani

Age:18

Depertment:CST


Name:Asif

Name:Musa

Name:Ani

No comments:

Post a Comment