1. What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm based on the concept of "objects", which can contain data in the
form of fields (attributes) and code in the form of procedures (methods). It promotes better structure,
code reusability, and scalability.
2. What is a Class?
A class is a user-defined blueprint or prototype from which objects are created. It defines properties
(attributes) and behaviors (methods) common to all objects of that type.
3. What is an Object?
An object is an instance of a class. It represents a real-world entity and consists of states and
behaviors defined by the class.
4. What is Inheritance?
Inheritance is a mechanism where one class (child/subclass) can inherit the properties and behaviors
(methods) of another class (parent/superclass). It promotes code reuse.
5. What is Polymorphism?
Polymorphism allows methods to perform different tasks based on the object that invokes them. It is
achieved in two ways: compile-time (method overloading) and run-time (method overriding).
6. What is Encapsulation?
Encapsulation is the concept of wrapping data and methods that operate on the data within a single
unit (class), and restricting access to some of the object's components for security and modularity.
7. What is Abstraction?
Abstraction means hiding complex implementation details and showing only the essential features of
the object. It reduces programming complexity and enhances security.
8. What is the difference between Class and Object?
A class is a blueprint or template, while an object is a concrete instance of the class. A class defines
structure and behavior; objects represent real entities using those definitions.
9. What is Method Overloading?
Method overloading is the ability to define multiple methods with the same name but different
parameter lists within the same class. It supports compile-time polymorphism.
10. What is Method Overriding?
Method overriding occurs when a subclass provides a specific implementation of a method that is
already defined in its parent class. It supports run-time polymorphism.
11. What is a Constructor?
A constructor is a special method that is automatically called when an object is instantiated. It is used
to initialize objects.
12. What is the difference between Constructor and Method?
A constructor initializes the object and has the same name as the class, while a method defines
behavior and can have any name. Constructors do not return values; methods do.
13. What is a Destructor?
A destructor is a method that is automatically invoked when an object is destroyed. It is used for
cleanup before the object is removed from memory (available in C++, not explicitly in Java/Python).
14. What is the significance of ‘this’ keyword?
The this keyword refers to the current instance of the class. It is used to differentiate between local
variables and instance variables when they have the same name.
15. What is Access Specifier?
Access specifiers define the visibility or scope of a class member. Common access specifiers are
public, private, protected, and default.
16. What is the difference between Abstract Class and Interface?
Abstract Class: Can have both abstract and non-abstract methods. Used for partial abstraction.
Interface: Can only have abstract methods (before Java 8), used for full abstraction and multiple
inheritance.
17. What is Multiple Inheritance?
Multiple inheritance is when a class can inherit from more than one class. While it is supported in
C++, it is not allowed directly in Java due to ambiguity issues. Java supports it through interfaces.
18. What is the difference between Static and Non-static members?
Static members belong to the class and are shared among all objects.
Non-static members belong to individual instances and are unique to each object.
19. What is a Final Keyword?
The final keyword is used to restrict the user. It can be applied to variables (constant), methods
(cannot be overridden), and classes (cannot be inherited).
20. What is Association, Aggregation, and Composition?
Association: A general relationship between two classes.
Aggregation: A "has-a" relationship with shared ownership.
Composition: A stronger "has-a" relationshi
p with exclusive ownership and lifecycle dependence.