Interfaces And Abstract Classes - Study Mode

[#176] In Java, can an abstract class have default methods with implementations?
Correct Answer

(D) Yes, starting from Java 8, abstract classes can have default methods with implementations

[#177] In Java, can an interface have private methods with implementations?
Correct Answer

(C) Yes, starting from Java 9, interfaces can have private methods

[#178] In Java, can an abstract class extend another class?
Correct Answer

(B) Yes, abstract classes can extend both abstract and concrete classes

Explanation

Solution: In Java, abstract classes can extend both abstract and concrete classes. When an abstract class extends another class (whether abstract or concrete), it inherits the properties and methods of that class. An abstract class is allowed to inherit from a concrete class and can override or use the methods from the superclass. Option A is incorrect because abstract classes can extend other classes. Option C is incorrect since there is no requirement for the superclass to be marked as "static." Option D is incorrect as the subclass does not need to be marked "final" to extend a class.

[#179] What is the purpose of the "extends" keyword in Java?
Correct Answer

(D) To create a subclass

[#180] In Java, can an interface extend another interface?
Correct Answer

(C) Yes, an interface can extend multiple interfaces