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
Can singleton class be inherited in java?
Define a java class.
Name few "optional" classes introduced with java 8 ?
Which programming language is best in future?
Can we call virtual funciton in a constructor ?
Are arrays dynamic in java?
What is serial version uid and its importance in java?
Why is stringbuffer thread safe?
Explain public static void main(string args[]) in java.
Is java developer a good career?
What 5 doubled?
How do you remove an element from an arraylist in java?
How to access arraylist elements in java?
Why can't we override private static methods?
what are synchronized methods and synchronized statements? : Java thread