[Arnab]: So can I say that Constructors can either have no return type or can have only "void" return type ?
No, because as Marilyn said, if there's a return type (including void), it's not a constructor anymore. Unfortunately this is a case where "try it and see" doesn't really give you a clear answer. The code compiles, but it doesn't do what you think it does.
[Arnab]: does it mean that it is possible to have methods with same name as the class name which are not constructors ?
Yes, unforturnately. This is an extremely bad idea, something that you should never do when writing a program (because it's needlessly confusing to everyone), and I wish that Sun had forbidden this in the first place. Unfortunately, they didn't. So you must remember it yourself: never put a return type, including void, on a constructor - or it stops being a constructor.
"I'm not back." - Bill Harding, Twister
Joined: Apr 21, 2005
Yeah, my bad. The example I gave doesn't compile - but for a different reason (no return statement).