KEMBAR78
Empolyee Java | PDF
0% found this document useful (0 votes)
5 views2 pages

Empolyee Java

Uploaded by

bmrajesh2007
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)
5 views2 pages

Empolyee Java

Uploaded by

bmrajesh2007
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/ 2

Employee.

java

public class Employee {

// Attributes

private int id;

private String name;

private String department;

private double salary;

// Constructor

public Employee(int id, String name, String department, double salary) {

this.id = id;

this.name = name;

this.department = department;

this.salary = salary;

// Getters

public int getId() {

return id;

public String getName() {

return name;

public String getDepartment() {

return department;

}
public double getSalary() {

return salary;

// Display method

public void displayDetails() {

System.out.println("Employee ID: " + id);

System.out.println("Name : " + name);

System.out.println("Department : " + department);

System.out.println("Salary : $" + salary);

System.out.println("---------------------------");

EmployeeDetailsApp.java

public class EmployeeDetailsApp {

public static void main(String[] args) {

// Create employee objects

Employee emp1 = new Employee(101, "Alice Johnson", "HR", 50000);

Employee emp2 = new Employee(102, "Bob Smith", "IT", 65000);

Employee emp3 = new Employee(103, "Charlie Brown", "Finance", 60000);

// Display employee details

emp1.displayDetails();

emp2.displayDetails();

emp3.displayDetails();

You might also like