All 114 questions

  1. What is object-oriented programming, and can you explain its four main principles with examples?

    Asked in 41 of 347 interviews · last asked Oct 22 · Concept · Junior

    Show answer

    Object-oriented programming (OOP) organizes code around objects that combine data and behavior. Encapsulation controls access to an object's state, while abstraction exposes useful operations without showing implementation details. Inheritance lets a class build on another class. Polymorphism lets different object types respond to the same operation in their own ways.

    • Encapsulation: a bank account hides its balance and allows changes only through methods that enforce valid transactions.
    • Abstraction: callers use account.withdraw(amount) without knowing how the account stores transactions.
    • Inheritance: ElectricCar extends Car, reusing its behavior and adding battery-related features.
    • Polymorphism: Circle and Rectangle both provide draw(), but each draws a different shape.

    What the interviewer checks: The interviewer checks whether you can explain all four principles, distinguish them, and connect them to practical examples.

    Common mistake (in 6 of 15 reviewed answers): Many answers forget that abstraction hides implementation details, while encapsulation controls access to an object's state.

    Other ways it was asked
    • “What is object-oriented programming?”
    • “What is OOP?”
    • “What are the main principles of object-oriented programming?”
  2. What are classes and objects, and how do they differ?

    Asked in 10 of 347 interviews · last asked Oct 17 · Concept · Junior

    Show answer

    A class defines the fields and methods that its objects can have. An object is an instance of a class, with its own identity and values for its instance fields. One class can be used to create many objects.

    • A class describes a type; an object is a specific instance of that type.
    • Objects of the same class can hold different values in their instance fields.
    • In Java, static fields belong to the class, not to each object.
    Code
    class Car {
        String color;
    }
    
    class Demo {
        public static void main(String[] args) {
            Car car = new Car();
            car.color = "red";
        }
    }

    What the interviewer checks: The interviewer is checking whether you can separate a class definition from an instance and its state.

    Other ways it was asked
    • “What is the difference between a class and an object?”
    • “What is a class?”
    • “What is an object?”
  3. What are static methods, and how do they differ from instance methods?

    Asked in 9 of 347 interviews · last asked Oct 18 · Concept · Junior

    Show answer

    Static methods belong to a class and can be called without creating an object. In Python, they receive no automatic instance or class argument. Instance methods receive the object as `self` and can use its state. Python class methods receive the class as `cls`, so they can work with class-level state.

    • In Python, use `@staticmethod` for static methods and `@classmethod` for class methods.
    • Static methods can access object state if an object is explicitly passed to them.
    • Use instance methods for object behavior; use static methods for related helpers that need no instance.

    What the interviewer checks: The interviewer checks whether you understand which methods receive an object, a class, or neither automatically.

    Common mistake (in 6 of 9 reviewed answers): Many answers forget that static methods need no object, while instance methods receive a particular object automatically.

    Other ways it was asked
    • “What are static variables and static member functions in C++?”
    • “How do static variables and static member functions differ from their non-static counterparts in C++?”
    • “What is a static member function in C++?”
  4. What is encapsulation, and can you explain its benefits with an example?

    Asked in 9 of 347 interviews · last asked Oct 22 · Concept · Junior

    Show answer

    Encapsulation keeps an object's data and the code that manages it together, and controls access through a defined interface. It helps prevent invalid state and allows internal changes without changing how callers use the object. Hiding means callers need not depend on implementation details, not that the source code is secret.

    • Private fields prevent callers from changing data directly.
    • Public methods enforce rules and expose only the operations callers need.
    • Internal storage and helper methods can change while the public interface stays stable.
    Code
    class Thermostat {
        private int temperature = 20;
        public void setTemperature(int value) {
            if (value < 10 || value > 30) {
                throw new IllegalArgumentException("Temperature must be 10 to 30");
            }
            temperature = value;
        }
        public int getTemperature() { return temperature; }
    }

    What the interviewer checks: The interviewer checks whether you understand how controlled access protects valid state and reduces dependence on internal details.

    Other ways it was asked
    • “What is encapsulation?”
    • “Can you give examples of implementation details that encapsulation hides?”
    • “How does encapsulation hide implementation details when the source code is accessible?”
  5. What is a constructor, and how does it differ from a method?

    Asked in 4 of 347 interviews · last asked Oct 8 · Concept · Junior

    Other ways it was asked
    • “What is a constructor?”
    • “What is a constructor in Java?”
    • “What is a constructor in Java, and how is a method different from a constructor?”
  6. What is the difference between a class and a struct in C#?

    Asked in 3 of 347 interviews · last asked Sep 10 · Concept · Mid-level

    Other ways it was asked
    • “In Swift, what is the difference between a struct and a class?”
    • “In Swift, what is the difference between a struct and a class, and why might you prefer a struct?”
    • “What is the difference between a struct and a class in C#?”
  7. What is self in a Python method, and what is it used for?

    Asked in 3 of 347 interviews · last asked Oct 22 · Concept · Junior

    Other ways it was asked
    • “What is the `self` parameter in Python, and is it required in an instance method?”
    • “What is the purpose of the self keyword in Python?”
  8. What is the `this` keyword used for in Java?

    Asked in 2 of 347 interviews · last asked Aug 18 · Concept · Junior

    Other ways it was asked
    • “Why and when is the `this` keyword used in Java?”
    • “What is the purpose of the `this` keyword in Java?”
  9. Can you explain object-oriented programming in Python?

    Asked in 2 of 347 interviews · last asked Sep 2 · Concept · Junior

    Other ways it was asked
    • “How does Python support object-oriented programming?”
    • “How do you use object-oriented programming in Python?”
  10. What is `__init__` in Python?

    Asked in 2 of 347 interviews · last asked Oct 18 · Concept · Junior

    Other ways it was asked
    • “What is __init__ in Python?”
  11. What is an access modifier in object-oriented programming?

    Asked in 2 of 347 interviews · last asked Jul 16 · Concept · Junior

    Other ways it was asked
    • “What is an access modifier in Java?”
  12. What is the difference between an instance variable and a class variable in Java?

    Asked in 2 of 347 interviews · last asked Jul 16 · Concept · Junior

    Other ways it was asked
    • “What is an instance variable in Java?”
  13. How can you check in Python whether an object is an instance of a particular type, such as `Apple`?

    Asked once · last asked Feb 24 · Write code · Junior

  14. Does a Python class have an implicit `__init__` method, and what class does it inherit from by default?

    Asked once · last asked Feb 24 · Concept · Junior

  15. What can an enum contain besides values, and can you add custom methods to it?

    Asked once · last asked Mar 4 · Concept · Mid-level

  16. In Python, how does `__new__` differ from `__init__`, and when would you override `__new__` instead of `__init__`?

    Asked once · last asked Mar 16 · Concept · Senior

  17. What is the difference between object-oriented programming and functional programming?

    Asked once · last asked Mar 17 · Concept · Mid-level

  18. If a controller passes an order object from a repository to a service method that changes its status to canceled, will the controller see the updated status when it continues using the same object?

    Asked once · last asked Mar 27 · Concept · Mid-level

  19. Which magic methods are available in PHP, and when are they called?

    Asked once · last asked Mar 27 · Concept · Mid-level

  20. If you needed to retrieve all the public methods of a class using reflection, how would you approach that in your code?

    Asked once · last asked Jun 13 · Write code · Junior

  21. If you had an object at runtime and needed to dynamically set the value of one of its private fields using reflection, how would you accomplish that?

    Asked once · last asked Jun 13 · Scenario · Mid-level

  22. Why should a User class's password field be encapsulated rather than directly accessible to other classes?

    Asked once · last asked Jun 20 · Concept · Junior

  23. What guidelines do you use to decide whether a class member should be private or public in C++?

    Asked once · last asked Jul 16 · Concept · Junior

  24. What is a metaclass in Python, and when would you use one?

    Asked once · last asked Jul 16 · Concept · Senior

  25. Can you give an example of when to use a class method versus an instance method in Python?

    Asked once · last asked Jul 16 · Concept · Mid-level

  26. How do you think about encapsulating data and encapsulating components in general?

    Asked once · last asked Jul 16 · Concept · Mid-level

  27. What access modifiers are available in Java, and how does `protected` differ from package-private access?

    Asked once · last asked Jul 22 · Concept · Junior

  28. In ES6 classes, how do you implement private state and ensure this is preserved when passing a method as a callback without manually binding everywhere?

    Asked once · last asked Jul 26 · Concept · Senior

  29. When would you choose a struct over a class in Swift, and how do value semantics affect state changes when that type is passed around your app?

    Asked once · last asked Aug 4 · Concept · Senior

  30. In PHP, what is the difference between self, static, and $this?

    Asked once · last asked Aug 12 · Concept · Mid-level

  31. What is the difference between delegates and closures?

    Asked once · last asked Aug 17 · Concept · Mid-level

  32. What is the difference between instance attributes and static attributes in ABAP OO?

    Asked once · last asked Aug 25 · Concept · Junior

  33. What are the visibility sections in OO ABAP?

    Asked once · last asked Aug 25 · Concept · Junior

  34. Can you explain what self and __init__ are in Python?

    Asked once · last asked Sep 8 · Concept · Junior

  35. How do you structure ABAP programs using object-oriented ABAP, and when would you use that approach?

    Asked once · last asked Sep 8 · Concept · Mid-level

  36. Why is OOP needed in Python, and what advantages does it bring to a project?

    Asked once · last asked Sep 16 · Concept · Junior

  37. How can an integer be a value type if it derives from System.Object?

    Asked once · last asked Sep 21 · Concept · Mid-level

  38. Why would you make an isPrime helper method private and static?

    Asked once · last asked Sep 28 · Concept · Junior

    Other ways it was asked
    • “Why did you make the isPrime helper method private and static?”
  39. What are the different types of inner classes in Java?

    Asked once · last asked Sep 30 · Concept · Junior

  40. What are the four principles of object-oriented programming, and how would you apply one in test automation?

    Asked once · last asked Oct 22 · Concept · Mid-level

    Other ways it was asked
    • “What are the four principles of object-oriented programming, and how have you applied one in test automation?”
  41. What are the basic object-oriented programming concepts in Java?

    Asked once · last asked Oct 22 · Concept · Junior

  42. Does a Java constructor return a value?

    Asked once · last asked Oct 8 · Concept · Junior

  43. What object-oriented programming features does C++ support?

    Asked once · last asked Jan 27 · Concept · Junior

  44. What benefits does encapsulation provide?

    Asked once · last asked Jan 27 · Concept · Junior

  45. When might you choose not to use encapsulation in a C++ solution?

    Asked once · last asked Jan 27 · Scenario · Mid-level

  46. Can a Kotlin data class be abstract?

    Asked once · last asked Feb 10 · Concept · Junior

  47. How do you create an instance of a class in Python?

    Asked once · last asked Feb 24 · Write code · Junior

  48. How do you call an instance method in Python to get its returned string?

    Asked once · last asked Feb 24 · Write code · Junior

  49. What does “instance” mean in Python?

    Asked once · last asked Feb 24 · Concept · Junior

  50. Can a class have two constructors?

    Asked once · last asked Mar 13 · Concept · Junior

  51. Can constructors return values?

    Asked once · last asked Mar 13 · Concept · Junior

  52. Which OOP pillar helps protect sensitive data?

    Asked once · last asked Mar 16 · Concept · Junior

  53. What does the static keyword do?

    Asked once · last asked Mar 25 · Concept · Junior

  54. What is a constructor in C#, and what types of constructors does it support?

    Asked once · last asked Mar 25 · Concept · Junior

  55. What is the purpose of a private constructor in C#?

    Asked once · last asked Mar 25 · Concept · Junior

    Other ways it was asked
    • “Which design pattern commonly uses a private constructor in C#?”
  56. What is a class in object-oriented programming?

    Asked once · last asked Mar 27 · Concept · Junior

  57. What is the primary goal of object-oriented programming, and why?

    Asked once · last asked Mar 31 · Concept · Junior

  58. What is OOP in Java, and what is encapsulation?

    Asked once · last asked Apr 8 · Concept · Junior

  59. What is the this keyword?

    Asked once · last asked Apr 8 · Concept · Junior

  60. What is a constructor in Python?

    Asked once · last asked Apr 9 · Concept · Junior

  61. What is an instance method in Java?

    Asked once · last asked Apr 23 · Concept · Junior

  62. What does the instanceof operator do in Java?

    Asked once · last asked Apr 23 · Concept · Junior

  63. Which object-oriented programming principles do you know?

    Asked once · last asked Apr 27 · Concept · Junior

  64. What is reflection?

    Asked once · last asked Apr 27 · Concept · Junior

  65. What are the different access modifiers in PHP?

    Asked once · last asked May 5 · Concept · Junior

  66. What is the difference between dynamically typed and statically typed languages?

    Asked once · last asked May 7 · Concept · Junior

  67. What is encapsulation in object-oriented programming?

    Asked once · last asked May 20 · Concept · Junior

  68. What does it mean for a function to return void or to be private or public?

    Asked once · last asked Jun 4 · Concept · Junior

  69. Is Go an object-oriented programming language?

    Asked once · last asked Jun 9 · Concept · Junior

  70. What does Go use to represent objects?

    Asked once · last asked Jun 9 · Concept · Junior

  71. Can a Java class have a private constructor?

    Asked once · last asked Jun 12 · Concept · Junior

  72. What do the month and year fields represent in a Date class?

    Asked once · last asked Jun 17 · Concept · Junior

  73. What does the public keyword specify in a class?

    Asked once · last asked Jun 17 · Concept · Junior

  74. What distinguishes a class from a method in object-oriented programming?

    Asked once · last asked Jun 17 · Concept · Junior

  75. What is object-oriented programming?

    Asked once · last asked Jun 20 · Concept · Junior

    Other ways it was asked
    • “Since you are working with Java and database connectivity, could you explain what object-oriented programming is?”
  76. What are constructors, and can a constructor be overloaded?

    Asked once · last asked Jun 20 · Concept · Junior

  77. What is the difference between primitive data types and objects in Java?

    Asked once · last asked Jun 21 · Concept · Junior

  78. What is a class in JavaScript?

    Asked once · last asked Jun 23 · Concept · Junior

  79. Is a private method accessible from within the class that defines it?

    Asked once · last asked Jun 24 · Concept · Junior

    Other ways it was asked
    • “Is this private method accessible in the same class, or does it show an error?”
  80. What are constructors and destructors used for during an object's lifecycle in C++?

    Asked once · last asked Jul 16 · Concept · Junior

  81. What is a class in Java? Give an example.

    Asked once · last asked Jul 16 · Concept · Junior

  82. What does it mean for C++ to be an object-oriented programming language?

    Asked once · last asked Jul 16 · Concept · Junior

  83. What is an example use case for object-oriented programming in Python?

    Asked once · last asked Jul 16 · Concept · Junior

  84. What are getters and setters in Java?

    Asked once · last asked Jul 10 · Concept · Junior

  85. How would you write a simple Apex class?

    Asked once · last asked Jul 13 · Write code · Junior

  86. How do protected members help a developer allow child classes to access certain parent data while keeping it hidden from external code?

    Asked once · last asked Aug 10 · Concept · Junior

  87. What is the difference between an instance and a class?

    Asked once · last asked Aug 12 · Concept · Junior

  88. What are classes in Python?

    Asked once · last asked Aug 13 · Concept · Junior

  89. Write a simple Python class and instantiate an object.

    Asked once · last asked Aug 14 · Write code · Junior

  90. Explain the basics of a Python class and object, including the key differences between a list and a tuple.

    Asked once · last asked Aug 14 · Concept · Junior

  91. In a bank account system, how are an account number, password, and balance associated with an account?

    Asked once · last asked Aug 14 · Concept · Junior

  92. Can you give a quick example of a class and object?

    Asked once · last asked Aug 14 · Concept · Junior

  93. Why is Java not 100% object oriented?

    Asked once · last asked Aug 20 · Concept · Junior

  94. What is procedural programming, and how does it differ from object-oriented programming?

    Asked once · last asked Aug 21 · Concept · Junior

  95. Can you explain what a constructor is in object-oriented programming?

    Asked once · last asked Aug 25 · Concept · Junior

  96. What does the new keyword do for classes?

    Asked once · last asked Aug 25 · Concept · Junior

  97. What are the events in OO ABAP?

    Asked once · last asked Aug 25 · Concept · Mid-level

  98. Can you explain object-oriented programming to your grandma?

    Asked once · last asked Sep 2 · Concept · Junior

  99. What is a method in Java, and how does it relate to the general concept of a function?

    Asked once · last asked Sep 4 · Concept · Junior

    Other ways it was asked
    • “What are functions and methods in Java, and how do they differ?”
  100. What is the difference between a function module and a method in ABAP?

    Asked once · last asked Sep 9 · Concept · Mid-level

    Other ways it was asked
    • “What is the difference between function module and method?”
  101. What is a wrapper class?

    Asked once · last asked Sep 17 · Concept · Junior

  102. What is the use of self in classes?

    Asked once · last asked Sep 24 · Concept · Junior

  103. How do you define a class in Python?

    Asked once · last asked Sep 25 · Concept · Junior

  104. What are the main concepts of object-oriented programming?

    Asked once · last asked Sep 26 · Concept · Junior

    Other ways it was asked
    • “How many types of OOP concepts are there?”
  105. What programming paradigms are you familiar with?

    Asked once · last asked Dec 18 · Concept · Junior

  106. What are nested classes in Java?

    Asked once · last asked Sep 30 · Concept · Junior

    Other ways it was asked
    • “What is the difference between nested and inner classes in Java?”
  107. Can you make a class static in Java?

    Asked once · last asked Oct 6 · Concept · Junior

  108. What is the difference between a class, an instance, and a method in Python?

    Asked once · last asked Oct 7 · Concept · Junior

  109. If two objects belong to the same class and I change one object's property, does the other object change?

    Asked once · last asked Oct 8 · Concept · Junior

  110. What is the difference between public and protected in Java?

    Asked once · last asked Oct 13 · Concept · Junior

  111. How do you declare and create an object in C++?

    Asked once · last asked Oct 16 · Concept · Junior

  112. What role does a constructor play when an object is created?

    Asked once · last asked Oct 16 · Concept · Junior

  113. When is class A's constructor called during object creation?

    Asked once · last asked Oct 16 · Concept · Junior

  114. What's the difference between public, protected, and private attributes?

    Asked once · last asked Oct 22 · Concept · Junior

More OOP and Design Patterns interview questions

How this list is made

Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.

Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.

The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every OOP and Design Patterns interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.

347 interviews, 240 candidates, Sep 2025 to Oct 2026. Updated every month with new interviews.