Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package inhert;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Player p1 = new Player();
  8. p1.Output();
  9.  
  10. System.out.println("\n");
  11.  
  12. Player p2 = new Player(
  13. "Bob",
  14. "Captain",
  15. "No",
  16. 1234,
  17. (short)99,
  18. (short)12,
  19. 18.9f);
  20.  
  21. p2.Output();
  22.  
  23. System.out.println("\n Subclass: \n");
  24.  
  25. PlayerV2 pv1 = new PlayerV2();
  26. pv1.Output();
  27.  
  28. System.out.println("\n");
  29.  
  30. PlayerV2 pv2 = new PlayerV2(
  31. "Bob",
  32. "Captain",
  33. "No",
  34. 1234,
  35. (short)99,
  36. (short)12,
  37. 18.9f,
  38. (short) 6);
  39.  
  40. pv2.Output();
  41. }
  42.  
  43. }
  44.  
  45.  
  46. // don't inherit constructors
  47. // java dosn't support multiple inheritance
  48. // new = new memory for an object
  49. // superclass first sub class is second
  50. // dont use colon but use extend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement