Constructors in Java

Constructors in Java

All-You-Need-to-Know-About-Java-Constructors-1280x800


● Constructor in java is a special type of method that is used to initialize the object.

● Java constructor is invoked at the time of object creation.

● It constructs the values i.e. provides data for the object that is why it is known as constructor.




● Rules for creating java constructor

   – There are basically two rules defined for the constructor.

   – Constructor name must be same as its class name

   – Constructor must have no explicit return type



● Types of java constructors

  – Default constructor (no-arg constructor)

  – Parameterized constructor


Post a Comment

0 Comments