maipathi notes
maipathi notes
Assignment:(Solution)
p1 : EmpAddress.java
package p1;
public class EmpAddress {
public String city,state;
public int pinCode;
i
public void getEmpAddress() {
thi
System.out.println("====EmpAddress====");
System.out.println("City:"+city);
System.out.println("State:"+state);
ipa
System.out.println("PinCode:"+pinCode);
}
}
p1 : EmpContact.java
Ma
package p1;
public class EmpContact {
sh
public String mailId;
public long phNo;
ate
}
}
Ve
p1 : Employee.java
package p1;
public class Employee {
public String empId,empName,empDesg;
public EmpAddress ea = new EmpAddress();
public EmpContact ec = new EmpContact();
public void getEmployee() {
System.out.println("====EmployeeData====");
System.out.println("EmpId:"+empId);
System.out.println("EmpName:"+empName);
System.out.println("EmpDEsg:"+empDesg);
}
}
p2 : DemoRef2.java(MainClass)
i
package p2;
thi
import java.util.Scanner;
ipa
import p1.*;
e.empId = s.nextLine();
e.empName = s.nextLine();
e.empDesg = s.nextLine();
e.ea.city = s.nextLine();
e.ea.state = s.nextLine();
System.out.println("Enter the EmpPinCode:");
e.ea.pinCode = Integer.parseInt(s.nextLine());
e.ec.mailId = s.nextLine();
i
e.ec.phNo = s.nextLong();
thi
e.getEmployee();
ipa
e.ea.getEmpAddress();
e.ec.getEmpContact();
s.close();
Ma
}
sh
}
ate
o/p:
Enter the EmpId:
nk
A111
Enter the EmpName:
Ve
Alex
Enter the EmpDeg:
SE
Enter the EmpCity:
Hyd
Enter the EmpState:
TS
Enter the EmpPinCode:
612345
Enter the EmpMailId:
[email protected]
Enter the EmpPhNo:
9898981234
====EmployeeData====
EmpId:A111
EmpName:Alex
EmpDEsg:SE
====EmpAddress====
City:Hyd
i
State:TS
thi
PinCode:612345
====EmpContact====
MailId:[email protected]
ipa
PhoneNO:9898981234
Ma
sh
ate
nk
Ve