fork(1) 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 ClassResolution {
  9. static class Parent {
  10. public static String name = "Sparsh";
  11. static {
  12. System.out.println("this is Parent");
  13. name = "Parent";
  14. }
  15. }
  16.  
  17. static class Child extends Parent {
  18. static {
  19. System.out.println("this is Child");
  20. name = "Child";
  21. }
  22. }
  23.  
  24. public static void main(String[] args) throws ClassNotFoundException {
  25. System.out.println(Child.name);
  26. System.out.println("----------------------");
  27. System.out.println(new Child());
  28. }
  29. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
this is Parent
Parent
----------------------
this is Child
ClassResolution$Child@25154f