Define encapsulation.
The bundling of data and methods that operate on that data within a single unit, or class.
What is inheritance in OOP?
A mechanism where a new class derives properties and behaviors from an existing class.
True or false: Polymorphism allows methods to do different things based on the object.
TRUE
Polymorphism enables a single interface to represent different underlying forms (data types).
Fill in the blank: Abstraction is the concept of hiding _______ details.
complex implementation
Define class.
A blueprint for creating objects, defining properties and methods.
What is an object in OOP?
An instance of a class that contains data and methods.
True or false: Interfaces can contain method implementations.
FALSE
Interfaces only declare methods without providing implementations.
Define method overriding.
A feature that allows a subclass to provide a specific implementation of a method already defined in its superclass.
What is method overloading?
Defining multiple methods in the same class with the same name but different parameters.
Fill in the blank: Static binding occurs at _______ time.
compile
Define dynamic binding.
The process of linking a procedure call to the code to be executed only at runtime.
What is a constructor?
A special method invoked when an object is created, initializing its properties.
True or false: Destructors are used to free resources when an object is no longer needed.
TRUE
Destructors are called automatically when an object goes out of scope.
Fill in the blank: Composition is a ‘has-a’ relationship, while inheritance is a ‘______’ relationship.
is-a
Define polymorphism.
The ability of different classes to be treated as instances of the same class through a common interface.
What is aggregation?
A form of association where one class contains references to objects of another class.
True or false: Abstract classes can be instantiated.
FALSE
Abstract classes are meant to be subclassed and cannot create objects directly.
Fill in the blank: Interfaces provide a way to achieve _______ in OOP.
multiple inheritance
Define single responsibility principle.
A class should have only one reason to change, meaning it should have only one job.
What is the open/closed principle?
Software entities should be open for extension but closed for modification.
True or false: Liskov substitution principle states that objects of a superclass should be replaceable with objects of a subclass.
TRUE
This principle ensures that a subclass can stand in for its superclass.
Fill in the blank: The interface segregation principle suggests that clients should not be forced to depend on _______ they do not use.
interfaces
Define dependency inversion principle.
High-level modules should not depend on low-level modules. Both should depend on abstractions.
What is dynamic polymorphism?
Polymorphism resolved at runtime, typically through method overriding.