Start Coding Now
🧩

OOP Concepts Interview Questions

Object-Oriented Programming pillars: Encapsulation, Inheritance, Polymorphism, Abstraction.

Class & ObjectInheritancePolymorphismAbstractionEncapsulation
1

Explain the four pillars of OOPs.

Easy
1. **Encapsulation**: Wrapping data (variables) and code (methods) together as a single unit. Achieved using private access modifiers. 2. **Inheritance**: Mechanism where one class acquires the properties and behaviors of another class. Promotes code reusability. 3. **Polymorphism**: Ability of an object to take many forms. Two types: Compile-time (Overloading) and Runtime (Overriding). 4. **Abstraction**: Hiding internal implementation details and showing only functionality. Achieved using abstract classes and interfaces.
2

Difference between Method Overloading and Method Overriding.

Medium
**Method Overloading (Compile-time Polymorphism)**: - Same method name, different parameter list (type, number, or order). - Occurs within the same class. - Return type doesn't matter. - Example: `add(int a, int b)` and `add(double a, double b)` **Method Overriding (Runtime Polymorphism)**: - Same method name, same parameters. - Occurs between superclass and subclass. - Return type must be same or covariant. - Example: Child class providing specific implementation for a method in Parent class.
3

Abstract Class vs Interface.

Medium
**Abstract Class**: - Can have both abstract and concrete methods. - Can have instance variables (state). - Supports constructors. - A class can extend only one abstract class. - Can have private/protected members. **Interface**: - Before Java 8, only abstract methods. Java 8+ supports default/static methods. - Variables are implicitly `public static final`. - No constructors. - A class can implement multiple interfaces. - Members are public by default.

Practice these concepts

Test your knowledge with our online compiler and practice problems.