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. class Base {
  8. private void display() {
  9. System.out.println("Static or class method from Base");
  10. }
  11. public void print() {
  12. System.out.println("Non-static or instance method from Base");
  13. }
  14. }
  15. class Derived extends Base {
  16. private void display() {
  17. System.out.println("Static or class method from Derived");
  18. }
  19. public void print() {
  20. System.out.println("Non-static or instance method from Derived");
  21. }
  22. public class test {
  23. public static void main(String args[])
  24. {
  25. Base obj= new Derived();
  26. obj1.display();
  27. obj1.print();
  28. }
  29. }
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:26: error: cannot find symbol
obj1.display();
^
  symbol:   variable obj1
  location: class Derived.test
Main.java:27: error: cannot find symbol
obj1.print();
^
  symbol:   variable obj1
  location: class Derived.test
Main.java:23: error: Illegal static declaration in inner class Derived.test
public static void main(String args[])
                   ^
  modifier 'static' is only allowed in constant variable declarations
3 errors
stdout
Standard output is empty