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 animal{
  9. String color = "white";
  10. }
  11. class dog extends animal{
  12. String color = "black";
  13. void printcolor(){
  14. System.out.println(color);
  15. System.out.println(super.color);
  16. }
  17. }
  18. class Ideone
  19. {
  20. public static void main (String[] args) throws java.lang.Exception
  21. {
  22. dog obj = new dog();
  23. obj.printcolor();
  24. // your code goes here
  25. }
  26. }
Success #stdin #stdout 0.1s 47016KB
stdin
Standard input is empty
stdout
black
white