Differentiate constructor and a method and how are it be
used?

Answer Posted / vishwanath

mainly there are
i.constructor name is same as the class name whereas method name doesn't.
ii.constructor is implicitly called when an object is created.....but the method is explicitly called by using object.
iii.constructor has no return type hence it doesn't return anything.....but method has return type.
iv.constructor is used to create and initialize data members.....where as method is created to code the specific task.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string made of?

535


What does file separator do in java?

546


Why string is a class?

550


Can java arraylist hold different types?

505


What are adapter classes?

612






How many digits is int32?

546


What is vector?

595


Explain runtime exceptions?

753


What is java in detail?

566


What is java reflection?

545


What are data structures in java?

537


What is finally in Java?

586


What is the main purpose of serialization in java?

538


Is there any case when finally will not be executed?

529


What do you mean by order of precedence and associativity?

550