Sunday, October 21, 2012

Java program to implement single inheritance


import java.io.*;
  class employee
  {
    private String empname;
    private  int empcode;

  void read(String s,int p)
  {
    empname= s;
    empcode=p;
  }
 void display()
  {
    System.out.println("The employee name is :" +empname);
    System.out.println("The employee code is :"+empcode);
  }
 }

 class labourer extends employee
 
  { private String labourtype;
    private int laboursalary;

  void read1()throws IOException
 
    {
       BufferedReader br= new BufferedReader( new InputStreamReader (System.in));
       System.out.println("Enter the employee name:");
       String a=br.readLine();
       System.out.println("Enter the employee code :");
       int p= Integer.parseInt(br.readLine());
       read(a,p);
       System.out.println("Enter the labourtype :");
       labourtype = br.readLine();
       System.out.println("Enter the labour salary :");
       laboursalary=Integer.parseInt(br.readLine());
    }

   void display1()
 
    {
    
      display();
      System.out.println(" The labour type is : "+ labourtype);
      System.out.println(" The labour salary is :"+laboursalary);   }
 }
class single   
    { public static void main (String s[])throws IOException
      {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter the number of employees");
        int n = Integer.parseInt(br.readLine());
        labourer l[]= new labourer[n];
        for(int i=0; i<n; i++)
        l[i]= new labourer();
        for(int i=0; i<n; i++)
        l[i] .read1();
        for(int i=0; i<n; i++)
      l[i].display1(); }
    }
Output

8 comments:

  1. Nice & Informative Blog !
    In case you are searching for the best technical services for QuickBooks, call us at QuickBooks Error 15106 1-855-977-7463 and get impeccable technical services for QuickBooks. We make use of the best knowledge for solving your QuickBooks issues.

    ReplyDelete
  2. Nice & Informative Blog !
    Given the recent outbreak of COVID 19, we at QuickBooks Customer Service Number don't just work hard but also help you get rid of the issue in less time.

    ReplyDelete
  3. Hey! What a wonderful blog. I loved your blog. QuickBooks is the best accounting software; however, it has lots of bugs like QuickBooks for MAC Support . To fix such issues, you can contact experts via QuickBooks Support Phone Number (855)963-5959.

    ReplyDelete
  4. I’m really happy to say it was an interesting post to read. I learned new information from your article on amity solved synopsis
    , you are doing a great job

    ReplyDelete
  5. With a nationwide presence, Active Detailing transforms every vehicle into a work of automotive art, leaving an indelible mark of excellence.

    ReplyDelete
  6. A guardrail is a protective device (pole, safety fence, etc.) used to prevent or mitigate damage caused by vehicle collisions within a factory. Many manufacturing plants are operated by forklifts, AGVs, and other vehicles. If these vehicles come into contact with workers or production equipment, serious industrial accidents and shutdowns can occur. In today’s guide, we will introduce you to the top 15 guardrail manufacturers of 2023. Read on to learn more.

    ReplyDelete
  7. A drop test machine is used to test the damage caused by dropping the product package and to evaluate the impact strength during transportation and handling. Our drop testers are used for the purpose of dropping tests while keeping the attitude of the specimen and investigating its effect. In addition, it can be used not only for electricity and electronics but also for drop tests in various fields such as medicine, food, and pharmaceutical.
    Linkotest has proudly served the drop test industry with mechanical drop testers for mobile products, rotating drum testers, drop testers for packages, and all types of drop testers for large items for over 23 years.

    ReplyDelete