Monday, April 30, 2007

What's the difference between constructors and other methods?

Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

1 comments :

Anonymous said...

Also a constructor does not have a return type where as methods have a return type.
Constructors are invoked only when creating new objects(using the new keyword) where was methods are invoked any number of times within a class / by an instance of a class.

 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2016. Reads: best tracker