How does the concept of interfaces promote flexibility and modularity in OOP?
- Interfaces allow for multiple inheritance in OOP.
- Interfaces are used for implementing data structures.
- Interfaces define a contract that classes must adhere to.
- Interfaces restrict access to class methods.
Interfaces in OOP provide a way to define a contract that classes must adhere to, promoting flexibility by allowing different classes to implement the same interface in their own way. This promotes modularity as it enables interchangeable components and reduces code dependencies.
Loading...
Related Quiz
- When would you use the Observer design pattern?
- What is the time complexity of the binary search algorithm?
- You're troubleshooting a network connectivity issue between two hosts. Describe the steps you would take to diagnose and resolve the problem using tools and techniques from the TCP/IP protocol suite.
- Which containerization technology is known for its lightweight and fast startup times?
- In an array, the ___________ gives the maximum number of elements that can be stored.