inheritance program in java

import  java.util.Scanner;

class Office
  {
     Scanner s=new Scanner(System.in);
  
    void getvalue()
    {
         System.out.println("super class office:-");
 System.out.println("enter employee name:-");
    String empname=s.nextLine();
   System.out.println("enter employee number:-");
    int a=s.nextInt();
   System.out.println("enter employee salary:-");
    int b=s.nextInt();
   
     }
  class Teching extends  Office   
   {
Scanner s=new Scanner(System.in);

void setvalue()
 {
super.getvalue();
System.out.println("subclass Teching=");
System.out.println("enter employee designition:-");
String designition=s.nextLine();
  }
}
class NonTeching extends  Office   
   {
Scanner s=new Scanner(System.in);

void setvalue()
{
super.getvalue();
System.out.println("subclass Teching=");
System.out.println("enter employee designition:-");
String designition=s.nextLine();
}
}
class Inheritance
  {
    public static void  main(String  []args)
     {
        NonTeching t2=new NonTeching();
      Teching  t1ss= new Teching();
     
           t1.setvalue();
           t2.setvalue();
       }
}
        
      
   
/*office
empno:
empname:
salary:
getvalue()
teahing::::::
designition:
setvalue()
Non-teahing:::
*/

Comments

Popular posts from this blog

Write a java program to calculate gross salary & net salary taking the following data

WAP a program that illustrates interface inheritance. Create two interface p1 and p2 . create Interface p which extends p1 and p2 and then create interface p12 which extends p12. Each interface declare one constants and one method. Create class Q which implements p12 and define all the methods of interface which displays value of constants

WAP that create interface on that you declare one method interest(p,r,n) then create two class simple and compound that implements interest and find simple and compound interest.