Computer Science, asked by puttaadarsh9539, 6 months ago

what is the difference between method and constructor in java​

Answers

Answered by Himanidaga
18

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 the method may/may not return a value.

Answered by jithendraprathipati2
2

Explanation:

Following are the difference between constructor and method.

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 the method may/may not return a value.

In case constructor is not present, a default constructor is provided by java compiler. In the case of a method, no default method is provided.

Constructor should be of the same name as that of class. Method name should not be of the same name as that of class.

Similar questions