Can an abstract class in Java have methods that are not abstract?
- No, all methods in an abstract class must be abstract.
- Yes, but they must be marked as 'final'.
- Yes, but they must be marked as 'private'.
- Yes, they can be both abstract and concrete.
In Java, an abstract class can indeed have both abstract and concrete methods. Abstract methods are meant to be overridden by subclasses, while concrete methods provide default behavior. They can have any access modifier (public, private, protected, or default).
Loading...
Related Quiz
- The ________ method of ExecutorService attempts to stop all actively executing tasks and halts the processing of waiting tasks.
- What is the impact of declaring a constructor private in a class?
- How does intrinsic locking in synchronized methods/blocks ensure thread safety?
- What method is commonly used to execute SQL queries in Java?
- If a class implements two interfaces with default methods having the same signature, the compiler will throw an error unless the class ________ the conflicting method.