Training Trains logo

OOP Concepts Explained Simply

By K. Boopathikumar, CEO & Founder · 1 November 2026 · Updated 22 November 2026 · 5 min read

Object-oriented programming is a favourite interview topic. Many students memorise the definitions and then cannot give an example. Everyday things can help.

A class is a plan, and an object is what you make from it. A house plan is a class, and each house built from it is an object.

Encapsulation keeps data safe inside and allows access through set methods. An ATM lets you withdraw money, but you cannot reach into the cash box.

Inheritance lets a new class reuse an existing one, as a Car and a Bike can both reuse Vehicle. Polymorphism lets one action behave differently: a start method works differently in each.

Abstraction hides the details. You press the brake without knowing how it works inside. Write a small example of each in your own language, and you will be able to explain it.

One example that shows all four

Imagine software for a bank. An Account class keeps the balance private and offers deposit and withdraw methods: that is encapsulation. SavingsAccount and CurrentAccount are both kinds of Account: that is inheritance. Both have a withdraw method, but the current account allows an overdraft: that is polymorphism. The cashier's screen calls withdraw without knowing how the rules work inside: that is abstraction.

Questions interviewers ask next

  • Overloading or overriding? Overloading means the same name with different parameters in one class. Overriding means a child class gives its own version of a parent's method.
  • Abstract class or interface? An abstract class can hold shared code and data. An interface mainly promises which methods will exist.
  • Why keep fields private? So that a wrong value, such as a negative balance, can be stopped in one place.
  • What is a constructor? The code that runs when an object is created, to give it a valid starting state.
  • Inheritance or composition? Use inheritance for "is a" and composition for "has a". A car is a vehicle, but it has an engine.

Common mistakes

  • Making a class for everything, even for a single function.
  • Deep inheritance: five levels that nobody can follow.
  • Getters and setters for every field, which leaves nothing protected.
  • Giving only the textbook definition when asked for an example.

Practise it

Write a small shop program with Product, Cart and Payment classes. Add a second payment type without changing the Cart. If you can do that, you have understood polymorphism. Then try the Java full stack tasks or the Java interview questions.

Looking for an internship near Erode?

10 days to 6 months, online or at our Erode and Perundurai branches, with real tasks reviewed by our team.

More guides