If you create a class without specifying any constructors the compiler will insert the default (no-arg) constructor for you. But if you create a constructor with an argument for a class, you will have to explicitly declare the no-arg constructor, the compiler will not add it for you. If you do not declare a no arg constructor you cannot create instances of a class like <code>Class a = new Class()</code>. This will not compile. You will have to create instances with the constructor you created only.<code>Class a = new Class(args)</code>. The real problem arises when you subclass this class. You will have to provide constructors which explicitly make calls to the superclass' constructor using super(args). [This message has been edited by Jim Hall (edited December 18, 2001).]
ravish: your stmts are not entirely correct. I would rephrase them like this: if you create an object of a class when no constr if defined then you won't get any compile time error
if you create an object of a class when no constr if defined, using a no argument constr, then you won't get any compile time error. and if you create an object of a class then you will get compile time error and if you create an object of a class, using a no argument constr, then you will get compile time error. Please note that you can still create objects of a class with the other constructors that are defined in the class provided you have access to them. regds. - satya ps: The most important fact abt the orig qstn is that we are discussing about the NO ARGUMENT CONSTRUCTOR.
Take a Minute, Donate an Hour, Change a Life