Constructor is a special member of a class which is used to initialize the state of an object. It provides the values to the data members at the time of object creation that is why it is known as constructor.
Constructor does not have an explicit return type but it returns current instance.
Java interview questions on main method
- What is constructor?
- Why default constructor is used?
- Does constructor return any value in java?
- Is constructor inherited in java?
- Can you make a constructor final in java?
- Difference between constructor and method in java?
- How to copy values from one object to another java?
- How to overload constructor in java?
- can you create an object without using new operator in java?
- What is constructor chaining in java?
- Why we use parameterized constructor in java?
- Can we call subclass constructor from superclass constructor?
- What happens if you keep return type for a constructor?
- What is the use of private constructor in java?
- Can a constructor call another constructor java?