Constructor vs Method in Java
Fast recall
Quick revision
Core answer
this(...) and super(...) chaining, so 'a constructor runs once' is not the full model.Whether you know the syntactic and semantic differences: name rule, no return type, called once via new.
Adding a return type to a constructor (which silently turns it into a regular method), or thinking constructors can be inherited.
Note that constructors aren't inherited but are chained via super(), and that a method named like the class but with a return type is just a method, not a constructor.
Interview-ready guide
Interview answer
The cleanest way to frame this is by what triggers each one. A constructor runs only when you write new — once, automatically, to set the object's starting state. A method you call yourself, by name, on an object that already exists, as often as you like. That difference in who calls it and when is the heart of the question.
Two rules make something a constructor: its name matches the class exactly, and it has no return type — not even void. That second rule is where people slip. Write void Account() {} and you haven't written a constructor at all, just an ordinary method that happens to share the class name — and the compiler stays quiet while your real setup never runs.
Constructors aren't inherited the way methods are; a subclass writes its own constructor and chains to the parent with super(). So a block with a return type sharing the class name? I read it as a method, every time.
Constructor vs Method in Java
Direct Answer
A constructor initializes a new instance. It has the class name and no declared return type, and Java invokes it as part of object creation. A method has its own name and return type and can be invoked after construction. One object-creation operation may run several constructors through this(...) and super(...) chaining, so 'a constructor runs once' is not the full model.
Code Example
class Account {
private double balance;
// CONSTRUCTOR: same name as class, NO return type
public Account(double opening) {
this.balance = opening; // initialize state on creation
}
// METHOD: any name, must have a return type (void here)
public void deposit(double amt) {
balance += amt; // behavior called on an existing object
}
// WARNING: this is a METHOD, not a constructor!
// public void Account() { } // <-- 'void' makes it an ordinary method
}
Account a = new Account(100); // constructor runs once, automatically
a.deposit(50); // method called explicitly, balance = 150
a.deposit(25); // called again — methods have no limit
Common Mistakes & Pitfalls
- Giving a constructor a return type — adding
void(or any type) silently demotes it to a regular method, so your initialization never runs and the bug compiles cleanly without a single warning. - Expecting constructors to be inherited — a subclass does not inherit the parent's constructors; it must define its own and reach the parent's via
super(). - Calling a constructor like a method — writing
obj.Student()won't compile; a constructor fires only throughnew, never on an object that already exists. - Assuming a no-arg constructor always exists — the moment you write any constructor of your own, the free default disappears and
new Student()stops compiling.
Check your understanding
Answer these without looking back at the article.
- What happens if you don't define any constructor in a class?
- Can a constructor be private? When would you use that?
- Can a constructor call another constructor?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.