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
What is purpose of find feature?
What is a method in programming?
Can a class extend more than one class?
How to declare objects of a class ?
What is OOP Language?
Explain how to convert any java object into byte array.
How do you do absolute value in java?
What is quick sort in java?
Is there any difference between nested classes and inner classes?
What are the java ide's? Explain
What is final method?
What is the use of hashmap in java?
What is thread synchronization in java?
What is the benefit of using enum to declare a constant?
How do you create a method in java?