LearnThatStack Ace your next interview
Computer Science Fundamentals

Object-Oriented Programming.

Start free Change topic Change

Practise Object-Oriented Programming one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.

Try one question

What are the four pillars of object-oriented programming?

The answer

Encapsulation, abstraction, inheritance and polymorphism are the four pillars.

  • Encapsulation keeps an object's data with the code that changes it, reachable only through the object's methods.
  • Abstraction shows what an object does and hides how it does it.
  • Inheritance lets one class build on another.
  • Polymorphism lets one piece of code work with several types.

The four overlap. Encapsulation and abstraction are two views of the same boundary. One hides state, the other hides steps. Inheritance is only one route to polymorphism, and often not the best.

Treat them as tools, not goals. Applying all four to every class produces deep hierarchies and wrappers that add nothing. The payoff is that a change lands in one file instead of twenty, and a new case plugs in without touching old code.

Example · what grading looks like
What is encapsulation, and what does hiding an object's state actually buy you?

“Encapsulation is keeping the data inside an object private, so other code has to go through its methods to change it. The way I think about it, the class owns its own rules. Take an Order with a status field. If status is public, any code can mark an order as shipped before it is paid. If the only way in is a ship method, that method checks payment first, and there is exactly one place to get that rule right. The other thing it buys you is freedom to change the internals. On one project we kept line items in an array and later switched to a map keyed by product id for faster lookups, and because nothing outside touched the array directly, none of the callers had to change.”

Knew it

Hits both: a single method guards the invariant and swapping the array for a map didn't touch callers. Could add that this also localizes debugging when state goes wrong.

Missed: Doesn't mention that encapsulation narrows where a bug can originate, since only the owning class can have changed the state.

Missed: No mention that encapsulation has a cost and isn't free for plain data holders with no real invariants.


Get your own answers graded

Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.

What it covers

All 90 questions

Each on its own page

Classes, objects and paradigms

What a class and an object are, how objects are built, passed and destroyed, and how OOP compares with procedural and functional styles.

7 questions

  1. What are the four pillars of object-oriented programming?
  2. What is the difference between a class and an object? Pro
  3. What is the difference between procedural and object-oriented programming? Pro
  4. What is a constructor, and what types of constructors are there? Pro
  5. When you pass an object to a method, is it by value or reference? Pro
  6. What is a destructor, and how does it differ from a finalizer? Pro
  7. What are the key differences between functional and object-oriented programming? Pro

Encapsulation and abstraction

Hiding state behind methods, access specifiers, choosing what a type shows, and why getters and setters alone are not encapsulation.

6 questions

  1. What is encapsulation, and what does hiding an object's state actually buy you?
  2. What is abstraction, and what techniques do you use to achieve it?
  3. Give a real-world example of abstraction and one of encapsulation Pro
  4. What are access specifiers and what is their significance in OOP? Pro
  5. How is encapsulation different from abstraction when they look so similar? Pro
  6. Do getters and setters really give you encapsulation, or just expose the fields? Pro

Inheritance and interfaces

Types of inheritance, abstract classes versus interfaces, single versus multiple inheritance and the diamond problem.

5 questions

  1. What is inheritance for, and what types of inheritance exist?
  2. How does an abstract class differ from an interface?
  3. Should a class hierarchy start from an interface or an abstract class? Pro
  4. Why do most languages allow many interfaces but only one base class? Pro
  5. What is the diamond problem, and how do languages resolve it? Pro

Polymorphism, overloading and overriding

Compile-time and runtime dispatch, overload rules, what can and cannot be overridden, static hiding, covariant returns and virtual functions.

9 questions

  1. What is polymorphism, and what types of polymorphism do languages support?
  2. What are the rules a method must follow to be a valid overload? Pro
  3. What is the difference between method overloading and method overriding? Pro
  4. Can a static method be overridden, or is it only hidden? Pro
  5. What is compile-time polymorphism, and how does it differ from runtime polymorphism? Pro
  6. Which methods can a subclass never override, and why not? Pro
  7. Can an overriding method declare a different return type than the original? Pro
  8. Why is calling a static method through an instance considered bad practice? Pro
  9. What is a virtual function and a pure virtual function? Pro

Composition versus inheritance

Has-a versus is-a, why composition is the default, the fragile base class problem, object relationships and mixins.

5 questions

  1. What is the difference between composition and inheritance?
  2. Why prefer composition over inheritance, and what does each approach cost you? Pro
  3. What are the limits of inheritance, including the fragile base class problem? Pro
  4. What is the difference between association, aggregation, and composition? Pro
  5. What is a mixin, and how does it compare with inheritance and composition? Pro

Object equality and hashing

Reference versus value equality, the equals and hashCode contract, collisions, entity ids, subclass checks and consistency with ordering.

7 questions

  1. What is the difference between reference equality and value equality? Pro
  2. When you override equals, what other method must you override, and why? Pro
  3. What must a correct equals method guarantee, including when it is given null? Pro
  4. Can two objects that are not equal share the same hash code? Pro
  5. Should an entity's id field take part in its equals method? Pro
  6. Should equals accept subclasses in its type check, or require an exact class match? Pro
  7. What breaks when equality and ordering comparison disagree about two objects? Pro

Immutability and copying

Building truly immutable classes, defensive and deep copies, and what immutability gives you for thread safety and hash keys.

6 questions

  1. What is an immutable class, and how do you recognise one? Pro
  2. What steps turn an ordinary class into a genuinely immutable one? Pro
  3. Are immutable objects automatically thread safe, and what makes them so? Pro
  4. Why do immutable objects make better hash map keys than mutable ones? Pro
  5. What is the difference between a shallow copy and a deep copy? Pro
  6. How do you keep a class immutable when one of its fields is mutable? Pro

Coupling and cohesion

Measuring how modules depend on each other and hang together, reducing coupling, and the Law of Demeter.

3 questions

  1. What do coupling and cohesion mean, and why aim for low coupling and high cohesion? Pro
  2. How do you reduce coupling between two classes that know too much about each other? Pro
  3. What is the Law of Demeter, and why does it matter? Pro

Single responsibility and interface segregation

One reason to change per class, splitting bloated classes and fat interfaces, and how SRP and ISP differ.

8 questions

  1. What is the Single Responsibility Principle, and what does it ask of a class? Pro
  2. What is the Interface Segregation Principle trying to prevent? Pro
  3. Describe a class that violates the Single Responsibility Principle and how you would split it Pro
  4. What goes wrong months later when one class carries several unrelated responsibilities? Pro
  5. An interface has ten methods but a class needs two - how do you fix that? Pro
  6. How does ISP relate to cohesion and coupling? Pro
  7. What's the difference between ISP and SRP? Pro
  8. What are the benefits and potential drawbacks of strictly following SRP? Pro

Open/closed and Liskov substitution

Extending behaviour without editing working code, patterns that enable it, balancing it with YAGNI, and keeping subtypes substitutable.

8 questions

  1. What is the Open/Closed Principle, and what is a real example of it? Pro
  2. What does the Liskov Substitution Principle ask of a subclass, and why? Pro
  3. A subclass cannot honour a method it inherits - why does that break LSP? Pro
  4. How do you add a new payment type without editing the existing classes? Pro
  5. What design patterns help achieve the Open/Closed Principle? Pro
  6. What are the key rules for maintaining LSP compliance? Pro
  7. How do you balance the Open/Closed Principle with YAGNI? Pro
  8. How do you identify and fix LSP violations in existing code? Pro

Dependency inversion and injection

Depending on abstractions, forms of injection, containers, inversion of control, service locators and the costs of indirection.

11 questions

  1. What is dependency injection, and how does it differ from creating objects yourself? Pro
  2. What are the three forms of dependency injection, and how do they differ? Pro
  3. What do you gain by injecting dependencies instead of constructing them inside a class? Pro
  4. What is a dependency injection container, and what work does it take over? Pro
  5. What does the Dependency Inversion Principle mean, and can you give an example? Pro
  6. What is inversion of control, and how does dependency injection relate to it? Pro
  7. What are the downsides and hidden costs of dependency injection? Pro
  8. What is Dependency Injection and how does it relate to DIP? Pro
  9. How do you apply DIP in scenarios without a DI container? Pro
  10. What are the trade-offs of applying DIP extensively? Pro
  11. How does a service locator compare with dependency injection? Pro

Applying SOLID in real code

SOLID as a whole: spotting violations, refactoring legacy and complex classes, conflicts between principles, performance and microservices.

10 questions

  1. What are the SOLID principles, and why do teams bother with them?
  2. How do SOLID principles relate to code maintainability and testability?
  3. A class that fetches, processes and formats a report - which SOLID principles break? Pro
  4. A method switching over a type code - which SOLID principles does that violate? Pro
  5. How do SOLID principles interact with each other? Can following one principle violate another? Pro
  6. How do you introduce SOLID principles to a legacy codebase? Pro
  7. How do SOLID principles apply to microservices architecture? Pro
  8. What metrics or code smells indicate SOLID principle violations? Pro
  9. How do you balance SOLID principles with performance requirements? Pro
  10. Can you provide an example of refactoring a complex class to follow all SOLID principles? Pro

More questions

5 questions

  1. What do public, private and protected mean, and when would you use each? Pro
  2. What is the difference between a class and an object? Pro
  3. What is the difference between a shallow copy and a deep copy of an object? Pro
  4. What is the Singleton pattern, and what problems does it cause? Pro
  5. In what order do field initialisers and constructors run when you create a subclass? Pro
Practice · Questions

All questions

Showing of 90
Beginner 30
01

What are the four pillars of object-oriented programming?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Encapsulation, abstraction, inheritance and polymorphism are the four pillars.

  • Encapsulation keeps an object's data with the code that changes it, reachable only through the object's methods.
  • Abstraction shows what an object does and hides how it does it.
  • Inheritance lets one class build on another.
  • Polymorphism lets one piece of code work with several types.

The four overlap. Encapsulation and abstraction are two views of the same boundary. One hides state, the other hides steps. Inheritance is only one route to polymorphism, and often not the best.

Treat them as tools, not goals. Applying all four to every class produces deep hierarchies and wrappers that add nothing. The payoff is that a change lands in one file instead of twenty, and a new case plugs in without touching old code.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is encapsulation, and what does hiding an object's state actually buy you?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Encapsulation means an object owns its data, and outside code reaches that data only through methods the object controls. Fields stay private, and the class decides which changes are legal.

Hiding state gives you three things:

  • You enforce invariants in one place, so an account refuses a withdrawal that goes below zero and no caller can skip that check.
  • You swap the internal representation, a list for a map, without touching callers.
  • When a balance is wrong, only one class can have changed it, so only that class needs checking.

The cost is extra code. A plain data holder passed between two functions gains nothing from private fields and pass-through accessors. The extra layer only makes the code longer to read.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is abstraction, and what techniques do you use to achieve it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Abstraction is deciding what to leave out. You name an operation by its intent and hide the steps behind that name. A caller writes save(order) and never learns whether that is a SQL insert, a file write or an HTTP call.

Four techniques do this. Interfaces state a contract with no implementation. Abstract classes fix a shape and leave gaps for subclasses. Ordinary methods give one name to a block of steps. Access modifiers back all of this up by keeping the internals out of reach.

A wrong abstraction costs more than none. If the contract you picked does not match how callers use the thing, every caller writes a workaround. Flags and special cases follow. Duplicated code is easier to fix later than a bad abstraction everyone depends on.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What is inheritance for, and what types of inheritance exist?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Inheritance lets one class take another's fields and behaviour as a starting point, then add to them or replace parts. It gives code reuse and a subtype relationship, so a dog can be passed anywhere an animal is expected. The second matters more.

Textbooks name the shapes by how the arrows point:

  • Single: one class extends one parent.
  • Multilevel: a chain, where a child is also a parent.
  • Hierarchical: several classes extend the same parent.
  • Multiple: one class extends more than one parent, which most languages allow for interfaces but not classes.

The split worth remembering is implementation inheritance versus interface inheritance. Taking a parent's code ties you to its internals, so its next change can break you. Taking only its contract does not.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is polymorphism, and what types of polymorphism do languages support?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Polymorphism means code written against one name works with many types, and the right version runs automatically. A loop calling shape.area() gets the circle's formula for circles and the square's for squares.

Languages support several flavours:

  • Subtype polymorphism: a subclass or implementation supplies its own version, and the object picks at runtime.
  • Ad-hoc polymorphism: one name, several parameter lists, resolved when the code is compiled. Operator overloading is the same idea.
  • Parametric polymorphism: generics, where one List<T> works for every element type.
  • Duck typing: in dynamic languages, any object with the right method fits.

The gain is that adding a type does not mean editing existing branches, so old code stays untouched. The cost is indirection. Reading a call site no longer tells you which method actually runs.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is the difference between composition and inheritance?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Composition means one object holds another and asks it to do work. Inheritance means one class is a specialised kind of another and receives its members automatically. A car has an engine, and an electric car is a car.

Three differences matter in practice.

  • Inheritance is fixed when the code is written, while a composed part can be swapped at runtime.
  • A subclass can see protected members, while a holder sees only the public members.
  • A subclass inherits the whole parent interface, wanted or not.

Both reuse code, but only inheritance also declares substitutability. That promise is what lets a subclass be passed where the parent is expected, and it is the part you cannot take back later. If all you want is reuse, composition makes no such promise, so the held part stays easy to change.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

How does an abstract class differ from an interface?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An interface states a contract and nothing else. An abstract class states a contract plus part of the implementation. It can hold fields, constructors and finished methods that subclasses share.

  • A class can implement many interfaces but extend only one abstract class. That makes an interface cheap to add to a type that already has a parent.
  • An abstract class can carry state and enforce an order of steps.
  • Classes from unrelated hierarchies can implement the same interface.

Some languages now let interfaces carry default method bodies. State and constructors still belong to classes. The choice comes down to whether subclasses share code, or only share a capability that callers depend on.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

What are the SOLID principles, and why do teams bother with them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

SOLID is an acronym for five design rules that keep code easy to change, test and reuse.

  • Single responsibility: a class should have one reason to change.
  • Open/closed: you can add behaviour without editing code that works.
  • Liskov substitution: a subtype must work wherever its base type does.
  • Interface segregation: small contracts beat one fat contract.
  • Dependency inversion: high-level code should depend on abstractions, not concrete classes.

Teams bother because each letter names a pain they have felt.

  • Shotgun edits across five files for one change.
  • An if chain that grows with every feature.
  • A subclass that throws from an inherited method.
  • Stubs full of empty methods.
  • Logic that cannot run without a real database.

Applied blindly, SOLID produces a class per line of logic, which is its own mess.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

What is the Single Responsibility Principle, and what does it ask of a class?

Part of Pro
10

What is the Open/Closed Principle, and what is a real example of it?

Part of Pro
11

What does the Liskov Substitution Principle ask of a subclass, and why?

Part of Pro
12

What is the Interface Segregation Principle trying to prevent?

Part of Pro
13

What is dependency injection, and how does it differ from creating objects yourself?

Part of Pro
14

What are the three forms of dependency injection, and how do they differ?

Part of Pro
15

What do you gain by injecting dependencies instead of constructing them inside a class?

Part of Pro
16

What is a dependency injection container, and what work does it take over?

Part of Pro
17

What do coupling and cohesion mean, and why aim for low coupling and high cohesion?

Part of Pro
18

What is the difference between reference equality and value equality?

Part of Pro Visual
19

When you override equals, what other method must you override, and why?

Part of Pro Visual
20

What must a correct equals method guarantee, including when it is given null?

Part of Pro
21

What is an immutable class, and how do you recognise one?

Part of Pro
22

What are the rules a method must follow to be a valid overload?

Part of Pro
23

Give a real-world example of abstraction and one of encapsulation

Part of Pro
24

What are access specifiers and what is their significance in OOP?

Part of Pro
25

What is the difference between a class and an object?

Part of Pro
26

What is the difference between procedural and object-oriented programming?

Part of Pro
27

What is a constructor, and what types of constructors are there?

Part of Pro
28

What does the Dependency Inversion Principle mean, and can you give an example?

Part of Pro Visual
29

What do public, private and protected mean, and when would you use each?

Part of Pro
30

What is the difference between a class and an object?

Part of Pro
Intermediate 45
31

Why prefer composition over inheritance, and what does each approach cost you?

Part of Pro
32

Should a class hierarchy start from an interface or an abstract class?

Part of Pro
33

Why do most languages allow many interfaces but only one base class?

Part of Pro
34

What is the diamond problem, and how do languages resolve it?

Part of Pro Visual
35

What are the limits of inheritance, including the fragile base class problem?

Part of Pro Visual
36

What is the difference between method overloading and method overriding?

Part of Pro Visual
37

Can a static method be overridden, or is it only hidden?

Part of Pro
38

What is compile-time polymorphism, and how does it differ from runtime polymorphism?

Part of Pro
39

Which methods can a subclass never override, and why not?

Part of Pro
40

Can an overriding method declare a different return type than the original?

Part of Pro
41

Why is calling a static method through an instance considered bad practice?

Part of Pro
42

How is encapsulation different from abstraction when they look so similar?

Part of Pro
43

Describe a class that violates the Single Responsibility Principle and how you would split it

Part of Pro
44

What goes wrong months later when one class carries several unrelated responsibilities?

Part of Pro
45

A subclass cannot honour a method it inherits - why does that break LSP?

Part of Pro
46

An interface has ten methods but a class needs two - how do you fix that?

Part of Pro
47

How do you add a new payment type without editing the existing classes?

Part of Pro
48

What is inversion of control, and how does dependency injection relate to it?

Part of Pro
49

What are the downsides and hidden costs of dependency injection?

Part of Pro
50

How do you reduce coupling between two classes that know too much about each other?

Part of Pro
51

Can two objects that are not equal share the same hash code?

Part of Pro Visual
52

Should an entity's id field take part in its equals method?

Part of Pro
53

What steps turn an ordinary class into a genuinely immutable one?

Part of Pro
54

Are immutable objects automatically thread safe, and what makes them so?

Part of Pro Visual
55

Why do immutable objects make better hash map keys than mutable ones?

Part of Pro Visual
56

When you pass an object to a method, is it by value or reference?

Part of Pro Visual
57

How do SOLID principles relate to code maintainability and testability?

Intermediate ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

SOLID makes code easier to maintain by keeping each change local, and easier to test by letting each class run on its own.

For maintainability, single responsibility gives each class one clear purpose, so a change is predictable and lands in one place. Dependency inversion puts abstractions between modules, which reduces the ripple effects of a change. Open/closed lets you extend behaviour without modifying code that works. Liskov substitution lets you swap one component for another without breaking callers.

For testability, dependency inversion and interface segregation mean a class depends on small interfaces. A test replaces those with mocks or stubs. Single responsibility keeps classes small and focused, so each one is easier to unit test.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

58

What design patterns help achieve the Open/Closed Principle?

Part of Pro
59

What are the key rules for maintaining LSP compliance?

Part of Pro
60

How does ISP relate to cohesion and coupling?

Part of Pro
61

What's the difference between ISP and SRP?

Part of Pro
62

What is Dependency Injection and how does it relate to DIP?

Part of Pro
63

What is the difference between a shallow copy and a deep copy?

Part of Pro Visual
64

What is the difference between association, aggregation, and composition?

Part of Pro
65

What is a virtual function and a pure virtual function?

Part of Pro Visual
66

What is a destructor, and how does it differ from a finalizer?

Part of Pro Visual
67

What is a mixin, and how does it compare with inheritance and composition?

Part of Pro
68

What is the Law of Demeter, and why does it matter?

Part of Pro
69

What are the key differences between functional and object-oriented programming?

Part of Pro
70

What are the benefits and potential drawbacks of strictly following SRP?

Part of Pro
71

How do you apply DIP in scenarios without a DI container?

Part of Pro
72

What are the trade-offs of applying DIP extensively?

Part of Pro
73

What is the difference between a shallow copy and a deep copy of an object?

Part of Pro
74

What is the Singleton pattern, and what problems does it cause?

Part of Pro
75

In what order do field initialisers and constructors run when you create a subclass?

Part of Pro
Expert 15
76

How do you keep a class immutable when one of its fields is mutable?

Part of Pro Visual
77

Should equals accept subclasses in its type check, or require an exact class match?

Part of Pro
78

What breaks when equality and ordering comparison disagree about two objects?

Part of Pro
79

Do getters and setters really give you encapsulation, or just expose the fields?

Part of Pro
80

A class that fetches, processes and formats a report - which SOLID principles break?

Part of Pro
81

A method switching over a type code - which SOLID principles does that violate?

Part of Pro
82

How does a service locator compare with dependency injection?

Part of Pro
83

How do you balance the Open/Closed Principle with YAGNI?

Part of Pro
84

How do you identify and fix LSP violations in existing code?

Part of Pro
85

How do SOLID principles interact with each other? Can following one principle violate another?

Part of Pro
86

How do you introduce SOLID principles to a legacy codebase?

Part of Pro
87

How do SOLID principles apply to microservices architecture?

Part of Pro
88

What metrics or code smells indicate SOLID principle violations?

Part of Pro
89

How do you balance SOLID principles with performance requirements?

Part of Pro
90

Can you provide an example of refactoring a complex class to follow all SOLID principles?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Object-Oriented Programming? Send them this set.
Quick recap

Object-Oriented Programming in pictures.

A quick recap of Object-Oriented Programming in 28 short animated pictures, one idea at a time. About 7 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 25 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

81 of 90 Object-Oriented Programming answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git