The default return type of a constructor is the object of the same class. You cannot make a constructor explicitly return any other data type. class Test { Test() { return ; } } In that case, compiler will not show any error. | 0 |
By: [email protected] On: Wed Aug 07 02:05:25 EDT 2013 0 392 0 | 392 |
Are You Satisfied :9Yes3No |
Constructors cannot return a value; they return the constructed object. You get an error because the compiler is looking for a constructor that takes a string as its argument. Since you did not declare a constructor the only constructor available is the default constructor that does not take any argument. Why do I say you did not declare a constructor? Because as soon as you declare a return value/type for your method it is not a constructor anymore but a regular method. | 0 |
By: [email protected] On: Wed Aug 07 02:26:04 EDT 2013 0 153 0 | 153 |
Are You Satisfied :2Yes0No |