Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Person
- {
- String name;
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- public void accept() throws IOException
- {
- System.out.print("\n\n\t Enter the name of the Person");
- name=br.readLine();
- }
- public void display()
- {
- System.out.print("\n\n\tPerson name="+name);
- }
- }
- class Student extends Person
- {
- String major;
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- public void accept() throws IOException
- {
- super.accept();
- System.out.print("\n\n\t Enter the major of the Person");
- major=br.readLine();
- }
- public void display()
- {
- super.display();
- System.out.print("\n\n\tPerson major="+major);
- }
- }
- class Instructor extends Person
- {
- float salary;
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- public void accept() throws IOException
- {
- super.accept();
- System.out.print("\n\n\t Enter the salary of the Person");
- salary=Float.parseFloat(br.readLine());
- }
- public void display()
- {
- super.display();
- System.out.print("\n\n\tPerson salary="+salary);
- }
- }
- public class Class_extend
- {
- Student s=new Student();
- s.accept();
- s.display();
- Instructor i=new Instructor();
- i.accept();
- i.display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement