Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import java.io.*;
  2. class Person
  3. {
  4. String name;
  5. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  6. public void accept() throws IOException
  7. {
  8. System.out.print("\n\n\t Enter the name of the Person");
  9. name=br.readLine();
  10. }
  11. public void display()
  12. {
  13. System.out.print("\n\n\tPerson name="+name);
  14. }
  15. }
  16. class Student extends Person
  17. {
  18. String major;
  19. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  20. public void accept() throws IOException
  21. {
  22. super.accept();
  23. System.out.print("\n\n\t Enter the major of the Person");
  24. major=br.readLine();
  25. }
  26. public void display()
  27. {
  28. super.display();
  29. System.out.print("\n\n\tPerson major="+major);
  30. }
  31. }
  32. class Instructor extends Person
  33. {
  34. float salary;
  35. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  36. public void accept() throws IOException
  37. {
  38. super.accept();
  39. System.out.print("\n\n\t Enter the salary of the Person");
  40. salary=Float.parseFloat(br.readLine());
  41. }
  42. public void display()
  43. {
  44. super.display();
  45. System.out.print("\n\n\tPerson salary="+salary);
  46. }
  47. }
  48. public class Class_extend
  49. {
  50. Student s=new Student();
  51. s.accept();
  52. s.display();
  53. Instructor i=new Instructor();
  54. i.accept();
  55. i.display();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement