Interview Q&A / Object-Oriented Programming

IntermediateQuick answer1 min readUpdated 3 Oct 2026

Are constructors and private members inherited in Java?

SHORT ANSWER

Constructors are never inherited; a child must define its own and call the parent's with super(). Private members exist inside the child object but cannot be accessed by name from the child.

Explain it simply

Think of a family locker. The child gets the contents of the house, but the parent's personal diary (private) stays locked; the child lives with it but cannot read it. And the parent's birth certificate (constructor) is for the parent only, so each child needs their own.

Example

java
class Parent {
    private int secret = 7;
    Parent(int x) { }
    int reveal() { return secret; }     // public path to the private field
}

class Child extends Parent {
    Child() { super(1); }               // must call a parent constructor
    int tryIt() {
        // return secret;               // compile error: private
        return reveal();                // fine
    }
}

System.out.println(new Child().tryIt());   // prints: 7

The secret field is physically part of every Child object, but only Parent code may name it.

What to say in the interview

"Constructors are not inherited; each class defines its own and chains to the parent with super(). Private fields are part of the child's object but not accessible directly, so the child uses protected or public methods of the parent."

Common mistakes

  • Saying private members are not part of the child object. They are stored there, just not visible by name.

#java#inheritance#constructors

Related questions

Practise more Object-Oriented Programming questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Object-Oriented Programming quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.