Advertisement
JeffGrigg

Method Name Overloading

Jul 12th, 2018
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.51 KB | None | 0 0
  1. /*public*/ class Parent {
  2.  
  3.     public void display(Object s) {
  4.         System.out.println("In Parent with " + s);
  5.     }
  6. }
  7.  
  8. /*public*/ class Child extends Parent {
  9.  
  10.     //    @Override
  11.     public void display(String s) {
  12.         System.out.println("In Child with " + s);
  13.         super.display(s);
  14.         ((Parent) this).display(s);
  15.     }
  16. }
  17.  
  18. public class OOPSMain {
  19.  
  20.     public static void main(String[] args) {
  21.         Child p = new Child();
  22.         p.display("Java is little complex");
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement