Difference Between Constructor and Method in Java.

There are following important differences between a constructor and method in java.

  • Constructor is used to initialize an object, whereas method is used to exhibits functionality of an object.
  • Constructors are invoked implicitly, whereas methods are invoked explicitly.
  • Constructor does not return any value, where method may/may not return a value.
  • Java compiler provides default constructor if there is no constructor, while this is not the case with method.
    • Constructor is invoked implicitly by the system, whereas a method is invoked by the programmer.
    • Constructor is invoked when a object is created using the keyword new. A method is invoked through method call.
    • Constructor initializes an object that does not exist. A method does operations on an already created object.
    • Constructor cannot be inherited by subclasses, while method can be inherited by subclasses.
  • Constructor name must be same as the class name, while the method name may or may not be same as class name.

Hope you have enjoyed reading this post. Please do write us if you have any suggestion/comment or come across any error on this page. Thank you for reading!



Share this page on WhatsApp

Get Free Tutorials by Email

About the Author

is the founder and main contributor for cs-fundamentals.com. He is a software professional (post graduated from BITS-Pilani) and loves writing technical articles on programming and data structures.