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
When is the finally clause of a try-catch-finally statement executed?
How strings are created in java?
What is method overloading in java ?
How many bits is a string?
What is a nested list?
Can a constructor be made final?
Is 0 true or false in java?
If system.exit (0); is written at the end of the try block, will the finally block still execute?
How do I enable java in safari?
Why is singleton instance static?
How is string immutable in java?
how is final different from finally and finalize in java?
What is the purpose of the runtime class in java programming?
Can we assign the reference to this variable?
Why do we need hashmap in java?