You are developing a system where you have multiple classes, and you want to ensure that a particular set of methods is available in all these classes. How would you ensure this?
- Inherit a base class with the common methods
- Use composition and create a separate class for the common methods
- Use global functions for the common methods
- Use interfaces to define the required methods
In JavaScript, you can't directly inherit from classes, but you can use interfaces to ensure a set of methods is available in implementing classes. Interfaces define method signatures that must be implemented by the classes that use them.
Loading...
Related Quiz
- You are developing a Python application where you need to store configuration settings. Which data type would you use to store key-value pairs of configuration settings?
- For supporting operations like obj[key], the class should define the _______ method.
- What method is used to add a single element to a set in Python?
- Your application needs to write user data into a file. To ensure data consistency, even if the application crashes during a write operation, what measure would you take?
- Which of the following tuple methods returns the number of times a specified value appears in the tuple?