When the following Java code is executed in eclipse, it gives the correct result (that is, it prints "class B"), but according to the java specification, the code cannot be compiled (since the superclass constructor requires an argument intand the constructor provided by the compiler to class B, includes calling the superclass no arg constructor, which is not defined), and when you try to compile a file using the javac command on the command line, it only compiles the superclass, that is, class A does not execute with the following compilation error:
B.java:8: cannot find symbol
symbol : constructor A()
location: class A
public class B extends A {
^
1 error
The following is the contents of the java file:
class A {
public A(int x) {
}
}
public class B extends A {
public static void main(String[] args) {
System.out.println("Class b");
}
}
Can someone explain how eclipse executes the main method without the ability to compile the class. Thanks in advance.
UPDATE
.class, eclipse bin, , , . - , , . eclipse , main, main ?