Interview Q&A / Object-Oriented Programming
Object-Oriented Programming interview questions
The four pillars, interfaces, abstract classes and design basics.
Prefer rapid revision? Practise Object-Oriented Programming short interview answers →
- Are constructors and private members inherited in Java?
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.
IntermediateQuick answer1 min read - Can an abstract class have a constructor? Why would it need one?
Yes. It cannot be instantiated directly, but a subclass constructor calls it with super() so the parent's fields get initialised.
IntermediateQuick answer1 min read