dineshkumar


{ City } chennai
< Country > india
* Profession * analyst
User No # 95275
Total Questions Posted # 0
Total Answers Posted # 1

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 12
Users Marked my Answers as Wrong # 3
Questions / { dineshkumar }
Questions Answers Category Views Company eMail




Answers / { dineshkumar }

Question { 4541 }

What is the difference between method and constructor ?


Answer

A method is a set of code that will perform a specific task. It must have a name which is accurate to the task it performs, must have a return type(if nothing must be prefixed with void), an optional access specifier, may have parameters/arguments. It is called whenever it is needed.A method can be overloaded and overridden.

A constructor is a special block of code which has the same name as its class name with no return type. It is executed only once for an instance of the class. It is, logically, used for initializing the object(its parameters). A constructor cannot be overridden but can be overloaded by differing no.of arguments.

Is This Answer Correct ?    12 Yes 3 No