0% found this document useful (0 votes)
3 views1 page

Constructor vs Method in Java

Constructors initialize objects while methods expose object behavior, constructors have no return type and are implicitly invoked while methods must have a return type and are explicitly invoked.

Uploaded by

Cristi Testing
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Constructor vs Method in Java

Constructors initialize objects while methods expose object behavior, constructors have no return type and are implicitly invoked while methods must have a return type and are explicitly invoked.

Uploaded by

Cristi Testing
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Constructor Java Method

A constructor is used to initialize the state of an object. A method is used to expose the behavior
of an object.

A constructor must not have a return type. A method must have a return type.

The constructor is invoked implicitly. The method is invoked explicitly.

The Java compiler provides a default constructor if you don't have The method is not provided by the
any constructor in a class. compiler in any case.

The constructor name must be same as the class name. The method name may or may not be
same as class name.

You might also like