Object-Oriented Programming Principles Flashcards
6 cards from real IKM practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Object-Oriented Programming Principles flashcards as text
What is encapsulation in OOP?
Answer: Bundling data and methods while restricting access to internal state
Encapsulation bundles data and methods within a class, hiding internal implementation.
What is the difference between overloading and overriding?
Answer: Overloading uses different parameters in same class; overriding redefines a parent method in subclass
Overloading provides same-name methods with different parameters; overriding redefines inherited methods.
What is an abstract class?
Answer: Class that cannot be instantiated and may contain abstract methods
Abstract classes cannot be instantiated and may have abstract methods subclasses must implement.
What is the Liskov Substitution Principle?
Answer: Subclass objects should be replaceable for superclass objects without breaking the program
LSP states subclass objects must work wherever superclass objects are expected.
What is composition over inheritance?
Answer: Favoring has-a relationships over is-a relationships for code reuse
Composition uses contained objects for behavior rather than extending classes.
What is the purpose of an interface in OOP?
Answer: Define a contract of methods implementing classes must provide
An interface defines method signatures that implementing classes must provide.