How can you create class methods that cannot be overridden by subclasses?
- By defining the method inside the constructor.
- By making the method static.
- By marking the method as final.
- By using the const keyword.
In many object-oriented programming languages, including JavaScript and Java, you can create methods that cannot be overridden by subclasses by marking them as final. This keyword indicates that the method is the final implementation and cannot be further overridden.
Loading...
Related Quiz
- You are developing a Python application where a certain function’s output is dependent on expensive computation. How would you use decorators to optimize this scenario?
- How can you retrieve the value associated with the key "name" from a dictionary d?
- How can you optimize the performance of a machine learning model that processes a large dataset?
- How would you define a class attribute that should not be overridden by subclasses?
- In which scenario might you use the built-in import() function instead of a regular import statement?