package aggregate;
class Address
{
int zipcode;
String city,street;
public Address(int zc,String cit,String st) // parametrized constructor.........
{
this.zipcode=zc;
this.street=st;
this.city=cit;
}
}
class employee
{
int emp_id ;
String name;
double salary;
Address a;
public employee(int id,String name,double salary,Address ad)
{
this.emp_id=id;
this.name=name;
this.salary=salary;
this.a=ad;
}
void display()
{
System.out.println("Emp id= "+emp_id);
System.out.println("Emp Name= "+name);
System.out.println("Emp Salary= "+salary);
System.out.println("Emp Address= "+a.zipcode+" - "+a.street+" - "+a.city);
}
}
public class Aggregate {
public static void main(String[] args)
{
Address ad=new Address(78650,"Karachi","Street-2");
employee emp=new employee(541,"salman",76000,ad);
emp.display();
}
}
No comments:
Post a Comment