Interview Q&A / Object-Oriented Programming

INTERVIEW Q&A · 69 QUESTIONS

Object-Oriented Programming interview questions

The four pillars, interfaces, abstract classes and design basics.

  1. What happens in memory when you write new Student("Asha") in Java?

    new allocates memory for the object on the heap, sets fields to default values, runs the constructor, and returns a reference. The variable on the stack holds only that reference.

    IntermediateQuick answer1 min read
  2. When does an object become eligible for garbage collection in Java?

    An object becomes eligible when no live thread can reach it through any chain of references. The JVM then frees its memory at a time of its own choosing.

    IntermediateQuick answer1 min read