Software Engineering Intern Interview Question

Explain the main ideas of object oriented programming with an example.

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Object oriented programming organises code around objects that bundle data with the methods that act on it. The four usual ideas are encapsulation, keeping internal state private behind methods; abstraction, exposing what an object does rather than how; inheritance, where a class reuses and extends another; and polymorphism, where different classes are used through a common interface. Many developers prefer composition to deep inheritance trees.

Why interviewers ask this

Most intern interviews include an object oriented question, because nearly every codebase uses these ideas. The interviewer wants clear definitions but, more importantly, a concrete example showing you understand why they matter. Mentioning that inheritance is easy to overuse, and that composition often gives more flexible designs, shows you have thought about design rather than just memorising the four pillars.

How to structure your answer

  • Describe objects and classes in a sentence.
  • Explain each principle with one running example.
  • Show why the principles make code easier to change.
  • Mention composition and the risk of overusing inheritance.

Example answer

Spoken example, first person

Object oriented programming groups data and the behaviour that works on it into objects, defined by classes. I will use a bank account as the example. Encapsulation means the balance is private, and you change it only through methods like deposit and withdraw, which can enforce rules such as not going overdrawn. Abstraction is related: code using the account only needs to know it can withdraw money, not how the transaction is recorded. Inheritance lets a savings account extend the base account, reusing its behaviour and adding interest. Polymorphism means code can work with any account through a shared interface. A monthly statement function can ask any account to calculate its fees, and each type applies its own rules, without the function checking which type it has. In a second year group project we leaned too heavily on inheritance and ended up with a deep hierarchy that was painful to change. Since then I prefer composition, building objects from smaller parts, unless there is a genuine is a relationship.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What is the difference between an interface and an abstract class?
  • Can you give an example where composition is better than inheritance?
  • What is the difference between overloading and overriding a method?

Related software engineering intern questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot