
Java OOPs Interview Questions And Answers
Crack Java interviews with these 20 OOP interview questions and answers. Learn key concepts like inheritance, polymorphism, abstraction, and more with clear examples.

Munaf Badarpura
July 14, 2025
10 min read
If you're preparing for Java interviews, one of the most important topics you’ll definitely come across is OOP - Object Oriented Programming. Almost everything in Java revolves around objects and classes. So understanding the core OOP concepts is a must for interview.
In this article, I’ve shared 20 commonly asked Java OOP interview questions in simple words. I have included code snippets where they make sense to clear things up. Let’s dive into the questions and answers.
1. What is an object-oriented paradigm?#
An object-oriented paradigm is a way of designing and writing code based on real-world objects.
Instead of just writing a bunch of functions, you create objects that have their own data (like properties) and behavior (like methods). Think of it as organizing your code like real-world objects—a car has wheels and can drive, a dog has a name and can bark.
It makes your code more modular, reusable, and easier to maintain. Java is built around this idea, using concepts like inheritance, polymorphism, and encapsulation to structure programs.
2. Why do we need OOPs?#
OOP makes life easier for developers! Here’s why:
- Modularity: You can break your program into smaller, self-contained objects, making it easier to manage.
- Reusability: Write a class once, and you can use it everywhere (like a blueprint).
- Scalability: Big projects are easier to handle because OOP organizes code logically.
- Maintainability: Fixing or updating code is simpler since changes are often limited to specific classes.
- Real-world modeling: It mimics how we think about the world (objects like cars, people, etc.), so it’s intuitive.
Without OOP, you’d end up with messy, hard-to-read code—especially for large projects.
3. What is a Class in Java?#
A class is like a blueprint for creating objects. It defines what an object can do (methods) and what data it holds (fields). For example, if you’re modeling a car, the class would define its properties (like color or speed) and behaviors (like drive or stop).
Here’s a simple example:
You can create multiple cars from this class, each with its own color and speed.
4. What is an Object in Java?#
An object is an instance of a class. Think of the class as the blueprint and the object as the actual thing built from it. For example, if Car is the class, an object would be a specific car, like a red Toyota going 60 km/h.
Here’s how you create an object:
5. What are the Features of OOPs?#
OOP in Java revolves around four main pillars:
- Encapsulation: Bundling data and methods together in a class and controlling access (like using private fields and public getters/setters).
- Inheritance: One class can inherit properties and methods from another (like a child inheriting traits from a parent).
- Polymorphism: Objects can take on multiple forms—like a method behaving differently based on the object calling it.
- Abstraction: Hiding complex details and showing only the necessary parts (like using an interface to simplify interactions).
These make your code flexible, secure, and easier to work with.
6. What is a Constructor and Types of Constructors?#
A constructor is a special method in a class that gets called when you create an object. It’s used to initialize the object’s properties. Constructors have the same name as the class and no return type.
There are two types of constructors:
- Default Constructor: Automatically provided by Java if you don’t define any. It initializes fields to default values (like 0 or null).
- Parameterized Constructor: Lets you pass values to initialize the object.
7. What is a Static Variable?#
A static variable belongs to the class, not to any specific object. It’s shared across all instances of the class. For example, if you want to count how many objects of a class are created, you’d use a static variable.
Here’s an example:
8. What is the this Keyword in Java?#
The this keyword refers to the current object. It’s super useful when you need to differentiate between instance variables and parameters with the same name.
For example:
Here, this.name refers to the class’s name field, while name is the parameter passed to the constructor.
9. What is Constructor Chaining in Java?#
Constructor chaining is when one constructor calls another constructor in the same class or a parent class. It’s a way to reuse code and avoid duplicating initialization logic.
You can chain constructors using this() (for the same class) or super() (for the parent class).
Example:
Here, the default constructor calls the parameterized constructor to set default values.
10. What is Inheritance?#
Inheritance lets one class inherit the properties and methods of another class. The class that inherits is called the child or subclass, and the class it inherits from is the parent or superclass. It’s great for code reuse.
Example:
A Dog object can use both eat() (from Animal) and bark().
11. Why is Multiple Inheritance Not Supported in Java?#
Java doesn’t allow a class to inherit from multiple classes (multiple inheritance) to avoid complexity and ambiguity. For example, if two parent classes have methods with the same name, which one should the child class use? This is called the diamond problem.
Instead, Java supports multiple inheritance through interfaces. A class can implement multiple interfaces, which don’t cause the same conflicts since they only define method signatures.
12. What is super in Java?#
The super keyword refers to the parent class. You can use it to:
- Call the parent class’s constructor (super()).
- Access the parent class’s methods or fields.
Example:
Here, super.name accesses the parent class’s name field.
13. What is Data Abstraction in Java?#
Data abstraction is about hiding the complex implementation details and showing only the necessary parts to the user. In Java, you achieve this using abstract classes or interfaces.
For example, you don’t need to know how a List works internally to use it, you just call methods like add() or remove().
Example with an abstract class:
The user only interacts with draw(), not the internal logic.
14. What are the Differences Between Abstraction and Encapsulation?#
- Abstraction: Focuses on hiding complexity and showing only what’s needed. It’s about the “what” (like interfaces or abstract classes).
- Encapsulation: Focuses on bundling data and methods together and controlling access (like using private fields with public getters/setters). It’s about the “how.”
Think of abstraction as designing the interface of a car (steering, pedals), while encapsulation is hiding the engine’s inner workings.
15. What is Polymorphism and Types of Polymorphism?#
Polymorphism means “many forms.” It lets objects of different classes be treated as objects of a common parent class. There are two types:
- Compile-time Polymorphism (Method Overloading): Same method name, different parameters in the same class.
- Runtime Polymorphism (Method Overriding): A subclass provides its own implementation of a parent class’s method.
16. Difference Between Method Overloading and Method Overriding in Java?#
- Method Overloading:
- Happens in the same class.
- Same method name, different parameters (number or type).
- Resolved at compile time.
- Example: add(int, int) and add(int, int, int).
- Method Overriding:
- Happens in a subclass.
- Same method name and signature as the parent class.
- Resolved at runtime.
- Example: Animal’s sound() overridden by Cat’s sound().
17. What is the final Keyword in Java?#
The final keyword in Java is used to restrict modification. It can be applied to:
- Variables: Makes them constant (can’t be changed once set).
- Methods: Prevents them from being overridden in subclasses.
- Classes: Prevents them from being extended.
Example:
If you try to extend Immutable or override display(), Java will throw an error.
18. Can we make the Interface final
?#
No, we can’t make an interface final
in Java.
Because final
means you can't extend or inherit it. But the whole point of an interface is to be implemented by other classes. If we make it final, no class would be able to implement it — which completely breaks the purpose of having an interface.
So yeah, the compiler won’t even allow it.
19. What is a marker interface?#
A marker interface is a special type of interface that doesn’t have any methods.
Its main job is to mark or tag a class so that the JVM or frameworks know something special about that class.
For example, Serializable
is a marker interface. When you make your class implement it, Java knows that your object can be converted into a byte stream.
So even though you don't write any methods, just by adding the interface, you're giving extra information about the class.
20. What is Method Hiding in Java?#
Method hiding happens when a subclass defines a static method with the same name and signature as a static method in the parent class. Unlike method overriding (which works with instance methods), the subclass method hides the parent class’s method, and the method called depends on the reference type, not the object type.
Example:
Conclusion#
That was a lot, but I hope it feels clearer now! Java’s OOP concepts are the backbone of the language, and understanding them will make you shine in interviews. Practice these questions, play around with the code snippets, and you’ll be ready to tackle any OOP question that comes your way.