Guest User

Untitled

a guest
Jun 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package pkgday3;
  2.  
  3. class Person
  4. {
  5. public void Name(String Name)
  6. {
  7.  
  8. System.out.println("name of a person:" +Name);
  9. }
  10. public void Year(int Year)
  11. {
  12.  
  13. System.out.println("year of birth of a person:" +Year);
  14. }
  15. }
  16. class Student extends Person
  17. {
  18. public void Major(String major)
  19. {
  20.  
  21. System.out.println("major of a person:" +major);
  22. }
  23. }
  24. class Instructor extends Person
  25. {
  26. public void salary(double Salary)
  27. {
  28.  
  29. System.out.println("salary of a person:" +Salary);
  30. }
  31. }
  32. public class Q2
  33. {
  34. public static void main(String[] args)
  35. {
  36. Person p=new Person();
  37. p.Name("xyz");
  38. p.Year(1996);
  39.  
  40. Student s1= new Student();
  41. s1.Major("Maths");
  42. Instructor i1= new Instructor();
  43. i1.salary(5000.0);
  44. }
  45.  
  46. }
Add Comment
Please, Sign In to add comment