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 does the this keyword mean in Java, and where do you use it?

    this is a reference to the current object, the one whose method or constructor is running. It is used to separate fields from parameters of the same name, to call another constructor, and to pass the current object along.

    BeginnerQuick answer1 min read
  2. What is self in Python class methods, and why must it be written?

    self is the first parameter of an instance method and receives the object the method was called on. Python passes it automatically; the name is only a convention.

    BeginnerQuick answer1 min read
  3. What is the difference between a class and an object?

    A class is a blueprint that describes the fields and methods something will have. An object is one real instance built from that blueprint, with its own values stored in memory.

    BeginnerQuick answer1 min read
  4. What is the difference between instance and static members of a class?

    An instance member belongs to each object and has a separate copy per object. A static member belongs to the class itself, exists once, and is shared by every object.

    BeginnerQuick answer1 min read
  5. When does Java provide a default constructor, and when does it not?

    If you write no constructor at all, the compiler adds a public no-argument one. The moment you write any constructor yourself, the compiler stops adding it.

    BeginnerQuick answer1 min read
  6. How do you make a property private in JavaScript classes?

    Prefix the field with

    IntermediateQuick answer1 min read