What is the difference between constructor and method?

Answer Posted / sameer inamdar

Constructor must have the same as the class name,
whereas we can give any name to the method.
Constructor doesnt have any return type not even void,
whereas method must have valid return type or void if
nothing is return.
Constructor will implicitely invoke at the time of
object creation, whereas method must invoke explicitely
with the object.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does java map allow duplicates?

493


What is finally in Java?

577


describe method overloading

539


what is mutual exclusion? : Java thread

556


What is data type in computer?

521






What is java argument list?

520


What is hash code collision?

592


Does constructor creates the object ?

584


How does sublist works in java?

542


If you do not want your class to be inherited by any other class. What would you do?

563


Is the milky way in a void?

540


Can we modify the throws clause of the superclass method while overriding it in the subclass?

549


What is the difference between class & structure?

569


What is jit compiler ?

576


What is difference between public static and void?

486