Methods Vs Constructors in Java
What is the difference between Methods and Constructors in Java?
No. |
Methods |
Constructors |
1
|
It is not necessary to use the same name of the class to create a Method.
|
The name of the Constructor should be same as the class name it
resides.
|
2
|
Method is an ordinary member function which is used to expose the behavior of an object
|
Constructor is a member function of a class used to initialize the
state of an object
|
3
|
Methods must have return type unless it is specified as void.
|
Constructor does not have a return type.
|
4
|
Compiler does not create a method in any case if one is not
available.
|
Java compiler creates default constructor if the program doesn’t have
one.
|
5
|
Methods invoked explicitly.
Invoked using the dot operator.
|
Constructor invoked implicitly. i. e. Invoked using the keyword ‘new’.
|
Great post. It definitely helped me. So thanks
ReplyDeleteGrid false Ceiling in chennai
Thank you for sharing this wonderful information with us. It was really helpful.
ReplyDeleteWeb designing course in Chennai
Well difference in both cases.
ReplyDeleteThanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeleteInterior Designers in Chennai
Pooja Room Interior Designers in Chennai
Modular Kitchen Interior Designers in Chennai
False Ceiling Interior Designers in Chennai
Tv Showcase Interior Designers in Chennai
Cupboard and Wardrobe Interior Designers in Chennai
Bedroom Interior Designers in Chennai
Living Room Interior Designers in Chennai