0% found this document useful (0 votes)
31 views3 pages

Experiment 14

Uploaded by

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

Experiment 14

Uploaded by

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

Experiment - 14

Objective :Create a Java Bean for Employee information (EmpID, Name, Salary, Designation and
Department).

Source Code : Main.java


public class Main {

public static void main(String[] args) {

Employee emp1 = new Employee(101, "virat", 5000.0,"Assistant" , "IT");

Employee emp2 = new Employee(103, "hardik", 1000.0,"Assistant" , "Cs");

Employee emp3 = new Employee(106, "rohit", 3500.0,"Lab Assistant" , "ME");

Employee emp4 = new Employee(123, "bumrah", 2900.0,"Assistant" , "EE");

// Print employee information\

System.out.println("Employees List");

System.out.println("Employee1:"+emp1);

System.out.println("Employee2:"+emp2);

System.out.println("Employee3:"+emp3);

System.out.println("Employee4:"+emp4);

System.out.println("After Modification in salaries:");

emp1.setSalary(80000.0);

emp2.setSalary(50000.0);

emp3.setSalary(90000.0);

emp4.setSalary(130000.0);

System.out.println("Updated Salary: ");

System.out.println("Employee1:"+emp1.getSalary());

System.out.println("Employee2:"+emp2.getSalary());

System.out.println("Employee3:"+emp3.getSalary());

System.out.println("Employee4:"+emp4.getSalary());

Employee.java
public class Employee {

private int empID; private


String name; private double
salary; private String
designation; private String
department;
public Employee(int empID, String name, double salary, String designation, String
department) { this.empID = empID;
this.name = name; this.salary
= salary; this.designation =
designation; this.department =
department;
}
public int getEmpID()
{ return empID;
}
public void setEmpID(int empID)
{ this.empID = empID;
}
public String getName()
{ return name;
}
public void setName(String name)
{ this.name = name;
}
public double getSalary()
{ return salary;
}
public void setSalary(double salary)
{ this.salary = salary;
}
public String getDesignation()
{ return designation;
}
public void setDesignation(String designation)
{ this.designation = designation;
}
public String getDepartment()
{ return department;
}
public void setDepartment(String department)
{ this.department = department;
}

@Override public String


toString() { return
"Employee{" +
"empID=" + empID +
", name='" + name + '\'' +
", salary=" + salary +
", designation='" + designation + '\'' +
", department='" + department + '\'' +
'}';
}
}

Output :

You might also like