Here is a code with no param constructor
public class misc2 {
misc2(String x){
}
public static void main(String ... args){
misc2 m = new misc2(); // this throws a compilation error
}
}
My question is why does it throw a compilation error, when Java automatically creates a default constructor, in this case misc2(){...}. if it is not defined already.
Also, now if I add a no param constructor misc2(){...}, which one is actually called by the JVM. Is it the default param or the no param. The second question is because if Java already creates a default constructor with no parameters already, the what is the need to explicitly create a constructor in some cases in the Java program?