0% found this document useful (0 votes)
8 views1 page

Getsalary Java

Uploaded by

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

Getsalary Java

Uploaded by

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

package JavaProgramsPkj;

class Employee
{
private int salary;
public Employee(int salary)
{
this.salary = salary;
}

public void work()


{
System.out.println("working as an employee!");
}

public int getSalary()


{
return salary;
}
}

public class HRManager extends Employee


{
public HRManager(int salary)
{
super(salary);
}

public void work() {


System.out.println("\nManaging employees");
}

public void addEmployee() {


System.out.println("\nAdding new employee!");
}

public static void main(String[] args)


{
Employee emp = new Employee(40000);
HRManager mgr = new HRManager(70000);

emp.work();
System.out.println("Employee salary: " + emp.getSalary());

mgr.work();
System.out.println("Manager salary: " + mgr.getSalary());
mgr.addEmployee();

}
}

You might also like