0% found this document useful (0 votes)
8 views4 pages

maipathi notes

Uploaded by

MONICA NAHAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

maipathi notes

Uploaded by

MONICA NAHAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Dt : 14/8/2023

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

public void getEmpContact() {


System.out.println("====EmpContact====");
System.out.println("MailId:"+mailId);
System.out.println("PhoneNO:"+phNo);
nk

}
}
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.*;

public class DemoRef2 {


Ma
public static void main(String[] args) {

Scanner s = new Scanner(System.in);

Employee e = new Employee();


sh
System.out.println("Enter the EmpId:");
ate

e.empId = s.nextLine();

System.out.println("Enter the EmpName:");


nk

e.empName = s.nextLine();

System.out.println("Enter the EmpDeg:");


Ve

e.empDesg = s.nextLine();

System.out.println("Enter the EmpCity:");

e.ea.city = s.nextLine();

System.out.println("Enter the EmpState:");

e.ea.state = s.nextLine();
System.out.println("Enter the EmpPinCode:");

e.ea.pinCode = Integer.parseInt(s.nextLine());

System.out.println("Enter the EmpMailId:");

e.ec.mailId = s.nextLine();

System.out.println("Enter the EmpPhNo:");

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

You might also like