Java MCQ: Which of the following statements about the ‘abstract’ keyword in Java is true?
Answer:
Explanation:
The abstract
keyword in Java is used to declare a class or method that is intended to be extended or implemented by other classes. An abstract method is a method that is declared without a body, meaning it does not contain any implementation. Such methods must be implemented by subclasses that inherit from the abstract class.
Abstract classes cannot be instantiated directly; instead, they are meant to be subclassed. If a subclass does not provide implementations for all abstract methods in the superclass, the subclass must also be declared abstract.
Understanding the use of abstract classes and methods is crucial for designing flexible and extendable code, allowing for the creation of complex class hierarchies.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html