Constructor Interview Questions

Reviewed by The Kiran Academy technical training team · Updated 13 September 2026 · Current Java

Java constructor: quick interview answer

A constructor is a special class member invoked during object creation to initialize the new object. It has the same name as its class and no return type. The new expression allocates the object; the constructor initializes it.
Default constructorThe compiler supplies one only when the class declares no constructor.
OverloadingConstructors can have different parameter lists but cannot be overridden.
InheritanceConstructors are not inherited; superclass initialization runs first.
First statementthis(...) or super(...), when used, must come first.
Interview trap: constructors cannot be static, final or abstract. Declaring any constructor stops Java from generating the no-argument default constructor.

Constructor rules interviewers test

QuestionCorrect answer
Is a constructor a method?No. The Java Language Specification says constructors are not members and have no result type.
Can it be inherited or overridden?No. Constructors are never inherited, hidden or overridden.
Can it be private?Yes. Private constructors can control instantiation, as in factories or singletons.
Can it throw exceptions?Yes. A constructor declaration can include a throws clause.
Do records have constructors?Yes. Records can declare canonical and compact canonical constructors.

Frequently asked questions

What happens if a class has no constructor?

Java implicitly declares a default constructor. Its accessibility follows the class, and it invokes the superclass no-argument constructor.

Can this() and super() be used together?

Not in the same constructor invocation position. A constructor can delegate to another constructor in the same class or directly invoke a superclass constructor.

Can an abstract class have a constructor?

Yes. It initializes the abstract class portion of each concrete subclass instance, although the abstract class itself cannot be instantiated directly.

Primary reference: Java Language Specification §8.8 — Constructor Declarations.

Is it mandatory to define a constructor in a class?

No, it is optional. If we do not define a constructor, compiler will automatically consider it as a default constructor.

Define a constructor.
  • Constructor is a special method provided in OOP language for creating and initializing an object.

  • In java, the role of a constructor is only to initialize an object and new key role is creating an object.

Learn about Java Constructor

Can we define a method with same name as that of the class?

Yes, it is allowed to define a method with same name as that of a class. No compile time error or runtime error will occur, but this practice is not recommended as per coding standards.

How can a compiler and a JVM differentiate between constructor and method definitions if both have same name as the class has?

A compiler and a JVM can differentiate between the definitions of the the constructor and method with the help of return type. If there is a return type then it is considered as a method else it is a constructor.

What are the rules for defining a constructor?
  • Constructor name should be same as class name.

  • It should not contain return type.

  • It should not contain non Access Modifiers such as final ,static, abstract, synchronized etc.

  • A logic return statement with a value is not allowed.

  • It can have all four accessibility modifiers i.e. private , public, protected and default.

  • It can have parameters.

  • It can have a 'throws' clause which means we can throw an exception from a constructor.

  • It can have a logic and as a part of logic it can have all java legal statements except the return statement with value.

  • We cannot place 'return' in constructor.

Why a return type is not allowed for constructor?

As there is a possibility of a method having the same name as class name, return type is not allowed in a constructor to differentiate constructor block from method block.

How does a compiler and JVM differentiate constructor and method invocations if both have same name as class name?

A compiler and a JVM differentiates constructor and method invocations by using 'new' keyword. If 'new' keyword is used in calling then a constructor is executed else method is executed.

Can we declare constructor as 'private'?
  • Yes we can declare a constructor as private.

  • All four access modifiers are allowed for a constructor.

  • We can declare a constructor as private if we do not want to allow a user to create an object from outside that class.

  • Basically we declare private constructor in Singleton design pattern.

Why a compiler given constructor is called as default constructor?

A constructor defined/given by a class is called as a default constructor because it obtains all its default properties from its class.

They are as mentioned below:

  1. Its accessibility modifier is same as its class accessibility modifier.

  2. Its name is same as class name.

  3. It does not have parameters and logic.

Why a constructor name is same as class name?
  • Every class object is created using the same 'new' keyword, so it must have information about the class to which it must create object.

  • For this reason constructor name should be same as class name.

What is default accessibility modifier of default constructor?

The default accessibility modifier of default constructor is assigned from its class.

In which situation it is mandatory for the developer to provide constructor explicitly?

A developer needs to provide constructor explicitly when one needs to execute some logic at the time of object creation. This logic might be object initialized logic or some other useful logic.

When does a compiler provide default constructor?

Only if there is no explicit constructor defined by developer then in such situation a compiler will provide a default constructor.

If class has an explicit constructor then will it have a default constructor?

No. Compiler places default constructor only if there is no explicit constructor.

What is constructor chaining?

Constructor Chaining is a technique of calling another constructor from one constructor. 'this()' is used to call same class constructor where as 'super()' is used to call super class constructor.

What will happen if one keeps a return type for a constructor?

If one keeps a return type for a constructor it will be treated as a normal method, but compiler gives a warning saying that method has a constructor name.

Can we call sub class constructor from super class constructor?

No. There is no way to call sub class constructor from a super class constructor in Java.

What is No-arg constructor?

Constructor without any arguments is called no-arg constructor. Default constructor in java is always known as no-arg constructor.

What is the use of private constructor?

Private constructors are used to restrict the instantiation of a class. When a class needs to prevent other classes from creating it's objects then private constructors are suitable for that. Objects to the class which has only private constructors can be created within the class. A very good use of private constructor is in singleton pattern. This ensures that only one instance of a class exists at any point of time. Here is an example of singleton pattern using private constructor.

Can we use this() and super() in a method?

No, we can't use this() and super() in a method.

What is a Default Constructor ?

The 'no argument' constructor provided by Java Compiler when no constructor is specified is known as a default constructor.

Learn about Constructor in our Video Tutorial

Can we overload constructors?

Yes, we can overload constructors.

Does a constructor create the object?

'New' operator in Java creates the objects. Constructor comes in the later stage in object creation. Constructor's job is to initialize the members after the object has reserved memory for itself.

What are the common uses of "this" keyword in java ?

"this" keyword is a reference to the current object and can be used for the following -

  1. Passing itself to another method.

  2. Referring to the instance variable when local variable has the same name.

  3. Calling another constructor in constructor chaining

If we place a return type in a constructor prototype will it throw an Error?

No, because compiler and JVM considers it as a method.


Ready for structured training?

Learn Java Full Stack with real projects

Live classes, practical projects, interview preparation and placement support in one guided programme.

View Java Full Stack Course Book Free Demo