Java MCQ: Which of the following best describes the concept of inheritance in Java?
Answer:
Explanation:
Inheritance in Java is a mechanism that allows a class (known as a subclass) to inherit methods and fields from another class (known as a superclass). This promotes code reuse and creates a natural class hierarchy. A subclass can also override methods from the superclass to provide specific implementations.
Java supports single inheritance through classes, meaning a class can inherit from only one superclass. However, a class can implement multiple interfaces, allowing for a form of multiple inheritance at the interface level.
Understanding inheritance is crucial for creating structured and reusable code in Java, enabling developers to build on existing functionality and create complex systems with minimal code duplication.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html