0 votes
1 view
in Java by (2.4k points)

1 Answer

0 votes
by (5.3k points)

Although constructors and methods operate in a very similar way, some differences do exist between them in terms of implementation, syntax, and theory:

  • A constructor is used to initialize an instance of a class while a method is used to express the behaviour of that class' instance. 
  • A constructor DOES NOT have a return type while a return type must be specified for a method.
  • Even if we don't define a constructor explicitly, a default constructor is still executed. But if we don't explicitly call for a method, that method will not be executed. 
  • A constructor has to be the same name as the class while a method may or may not have the same name as that of the class. 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !