fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Parent obj = new Child();
  14. obj.display();
  15. }
  16. }
  17. class Parent
  18. {
  19. int a=100;
  20. public void display()
  21. {
  22. System.out.println("Display in parent A: "+a);
  23. }
  24. }
  25.  
  26. class Child extends Parent
  27. {
  28. int b=200;
  29.  
  30. public void display()
  31. {
  32. System.out.println("Display in parent B: "+b);
  33. }
  34. }
Success #stdin #stdout 0.11s 48344KB
stdin
Standard input is empty
stdout
Display in parent B: 200