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

Contructor

A constructor in Java is a special method with the same name as the class, called when an instance of the class is created. It has no return type and initializes the object, with a default constructor provided by the Java compiler if none is defined. There are two types of constructors: no-arg and parameterized constructors.

Uploaded by

Anusha Jain
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)
6 views1 page

Contructor

A constructor in Java is a special method with the same name as the class, called when an instance of the class is created. It has no return type and initializes the object, with a default constructor provided by the Java compiler if none is defined. There are two types of constructors: no-arg and parameterized constructors.

Uploaded by

Anusha Jain
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

1.

Constructor is special class method which has same as class


name.
2. It is called when an instance of the class is created. i.e at a time
creation of object.
3. Every time an object is created at least one constructor is called.
4. It has no return type. Not even void.
5. A default constructor is called if there is no constructor available
in the class. The default constructor is provided by the Java
compiler.
6. It is a special type of method which is used to initialize the
object.
7. A Java constructor cannot be abstract, static, final, and
synchronized.

There are two types of constructors in Java:

(i) no-arg constructor.


(ii) Parameterized constructor.

You might also like