Guest User

Untitled

a guest
Feb 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class Father {
  2.  
  3. public String x;
  4.  
  5. public Father() {
  6. this.init();
  7. System.out.println(this);
  8. System.out.println(this.x);
  9. }
  10.  
  11. protected void init() {
  12. x = "Father";
  13. }
  14.  
  15. @Override
  16. public String toString() {
  17. return "I'm Father";
  18. }
  19.  
  20. void ParentclassMethod(){
  21.  
  22. System.out.println("Parent Class");
  23. }
  24.  
  25. }
  26.  
  27.  
  28. public class Son extends Father {
  29. public String x;
  30.  
  31.  
  32. @Override
  33. protected void init() {
  34. System.out.println("Init Called");
  35.  
  36. x = "Son";
  37. }
  38.  
  39. @Override
  40. public String toString() {
  41. return "I'm Son";
  42. }
  43.  
  44. @Override
  45. void ParentclassMethod(){
  46. super.ParentclassMethod();
  47. System.out.println("Child Class");
  48. }
  49.  
  50. }
  51.  
  52. public class MainCLass{
  53.  
  54. public static void main(String[] args){
  55.  
  56. Son ob = new Son();
  57.  
  58. }
Add Comment
Please, Sign In to add comment