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 are the loops in java?
Is arraylist ordered in java?
What is public static?
Can you declare a private method as static?
What is foreach loop in java?
What is an exception in java?
What is multithreading and its advantages?
What is the static variable?
What is the equal sign?
What is Mutex (Mutual Exclusion Object) ?
What is synchronization and why is it important in java programming?
What is the difference between serializable and externalizable interfaces?
What do you mean by order of precedence and associativity?
What is t in generics in java?
How can you add and remove nodes in jtree?