1️⃣ Which concept is not a core principle of OOP?
Answer: Compilation
Explanation: Compilation is related to how code is executed, not a concept of OOP. Core OOP principles are encapsulation, inheritance, abstraction, and polymorphism.
2️⃣ What is encapsulation in object-oriented programming?
Answer: Binding data and methods together while hiding internal details.
Explanation: Encapsulation protects data by restricting direct access using access modifiers (like private) and provides controlled access through methods.
3️⃣ Which keyword is used for inheritance in Java?
Answer: extends
Explanation: The extends
keyword is used in Java to inherit from a parent class. It allows the child class to access methods and variables of the parent.
4️⃣ What does polymorphism mean in OOP?
Answer: A single function behaving differently based on the object or context.
Explanation: Polymorphism allows objects to respond differently to the same method call depending on their class (method overriding or overloading).
5️⃣ What concept is achieved using abstract classes or interfaces?
Answer: Abstraction
Explanation: Abstraction hides the implementation details and shows only the relevant features. Abstract classes and interfaces help enforce abstraction in code.
Double Tap ❤️ For More
Top comments (1)
Just a fact