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 exception handling in java?
What are features of java?
How big is a 64 bit float?
Why should I use abstract class?
What is the difference between a vector & an array list?
What does sizeof return?
What is a hashmap used for?
What is the generic function?
Is there a jre for java 11?
What is finally in Java?
What happens when heap memory is full?
Explain how to force the garbage collection in java.
What is abstraction in java?
Why do we use predicate in java?
What are the differences between throw and throws?