Monday, 5 September 2011

Inheritance in a Company - Manager-Employee Inheritance in java

   
class Employee
{
    protected float salary;
   
    private String bname = "Vee Bank";
       
    public void showBankName()
    {
        System.out.println(bname);
    }
}

class Manager extends Employee
{
    public void setSalary(float salary)
    {
        super.salary = salary;
    }
   
    public float getSalary()
    {
        return super.salary;
       
    }
}


public class CompanyMain
{
    public static void main(String[] args)
    {
            Manager manager = new Manager();
                manager.setSalary(40000);
                manager.showBankName();
                System.out.println("Manager Salary : " + manager.getSalary());
    }
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.