0% found this document useful (0 votes)
43 views3 pages

Code Name Input: Import Class Protected Int Protected New Void

This Java code defines classes for different types of staff - Teacher, Typist, Officer, Regular, and Casual. The Staff class defines common code and properties for all staff like code and name. The subclasses extend and add specific properties - Teacher adds subject and publication, Typist adds speed, Officer adds grade, and Casual adds wages. The main method creates instances of Teacher, Typist and Officer, gets their details using methods, and displays the details.

Uploaded by

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

Code Name Input: Import Class Protected Int Protected New Void

This Java code defines classes for different types of staff - Teacher, Typist, Officer, Regular, and Casual. The Staff class defines common code and properties for all staff like code and name. The subclasses extend and add specific properties - Teacher adds subject and publication, Typist adds speed, Officer adds grade, and Casual adds wages. The main method creates instances of Teacher, Typist and Officer, gets their details using methods, and displays the details.

Uploaded by

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

import java.util.

*;

class Staff
{
protected int code;
protected String name;

Scanner input=new Scanner(System.in);


void getStaff()
{
System.out.println("Enter Code");
code=input.nextInt();

System.out.println("Enter Name");
name=input.next();

void displayStaff()
{
System.out.println("Code is"+code);
System.out.println("Name is"+name);

class Teacher extends Staff


{
private String subject, publication;

void getTeacher()
{
getStaff();

System.out.println("Enter Subject");
subject=input.next();

System.out.println("Enter Publication");
publication=input.next();

void displayTeacher()
{
displayStaff();

System.out.println("Subject:"+subject);
System.out.println("Publication:"+publication);

}
class Typist extends Staff
{
private int speed;

void getTypist()
{
getStaff();

System.out.println("Enter Speed");
speed=input.nextInt();

void displayTypist()
{
displayStaff();

System.out.println("Speed:"+speed);

}
class Officer extends Staff
{
private String grade;

void getOfficer()
{
getStaff();

System.out.println("Enter Grade");
grade=input.next();

void displayOfficer()
{
displayStaff();

System.out.println("Grade:"+grade);

class Regular extends Typist


{

class Casual extends Typist


{
private int wages;

void getCasual()
{
getTypist();
System.out.println("Enter Wages");
wages=input.nextInt();

void displayCasual()
{
displayTypist();
System.out.println("Wages"+wages);

public class EducationDetail {

public static void main(String[] args) {


Teacher teach=new Teacher();
Typist type=new Typist();
Officer Off=new Officer();

teach.getTeacher();
teach.displayTeacher();

type.getTypist();
type.displayTypist();

Off.getOfficer();
Off.displayOfficer();

You might also like