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