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 the difference between numeric and integer?
Which non-unicode letter characters may be used as the first character of an identifier?
What is stack class in java?
What is the difference between a synchronized method and a synchronized block?
What is the base class of all classes?
What are the six ways to use this keyword?
What is string builder?
Are there structures in java?
Why do we use bufferedreader?
How do you allocate memory to object?
how we can make a write-only class in java?
What if constructor is protected in java?
what is a thread pool in java and why is it used?
What is java and their uses?
Which object oriented concept is achieved by using overloading and overriding?