Constructor
Constructor
Constructor in Java
02 Features of constructor
01 What is a constructor ?
• Every time an object is created using the new() keyword, at least one constructor
is called.
04
Types of constructors
In Java, constructors can be divided into 3 types:
• Default Constructor.
• Parameterized Constructor.
• No-Arg Constructor.
Default constructor
• If we do not create any constructor, the Java compiler automatically create a constructor during
the execution of the program. This constructor is called default constructor.The default constructor
• A Java constructor can also accept one or more parameters. Such constructors are known as
• No argument constructor is the same as default constructor but you can write any code in body.
05
Overloaded constructor
• Similar to Java method overloading, we can also create two or more constructors
2. Block.