Home › Interview Questions › Tell me about OOP concepts in Java and give some e…

Tell me about OOP concepts in Java and give some examples.

🟡 Medium Conceptual Junior level
1Times asked
Oct 2026Last seen
Oct 2026First seen

💡 Model Answer

Object‑Oriented Programming (OOP) in Java is built around four core principles:

  1. Encapsulation – Bundling data (fields) and behavior (methods) into a single class and restricting direct access to the data. Example: A BankAccount class exposes deposit() and withdraw() methods while keeping the balance field private.
  1. Inheritance – Creating a new class (subclass) that inherits fields and methods from an existing class (superclass). Example: SavingsAccount extends BankAccount and adds an interest‑rate field.
  1. Polymorphism – The ability to treat objects of different subclasses through a common interface or superclass, allowing the same method call to execute different implementations. Example: A List interface with ArrayList and LinkedList implementations; calling add() on a List reference invokes the appropriate subclass method.
  1. Abstraction – Hiding complex implementation details behind simple interfaces or abstract classes. Example: An Animal abstract class defines an abstract makeSound() method; concrete classes like Dog and Cat provide specific implementations.

These concepts enable modular, reusable, and maintainable code. For instance, you can define an interface Shape with a draw() method, then implement Circle, Rectangle, and Triangle classes that each provide their own draw() logic, allowing a graphics engine to render any shape polymorphically.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500