Answer is E.
To test:
interface Downloadable {
public void download();
}
interface Readable extends Downloadable { // line n1
public void readBook ();
}
abstract class Book implements Readable { // line n2
public void readBook() {
System.out.println("Read Book");
}
}
class EBook extends Book { // line n3
public void readBook() {
System.out.println("Read E-Book");
}
//public void download() {} // It is necessary to implement the download() method in this class to compile.
}
public class Test {
public static void main (String [] args) {
Book book1 = new EBook();
book1.readBook();
}
}
The answer is letter E:
n1 -> Correct, one interface extends another interface.
n2 -> Correct, a class implements an interface and to remove the obligation to rewrite all interface methods, you must put the keyword "abstract" before "class".
n3 -> Wrong, like E-book and extends Book which implements the readable interface which extends another Downloadable interface, it inherits the "download()" method and because it is an interface, the E-book class needs to overload the method to compile or do like its parent Book class, put the keyword "abstract" before "class".
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
DJava
Highly Voted 5 years, 6 months agorasifer
Highly Voted 5 years, 5 months agoMPignaProTech
Most Recent 1 month, 4 weeks agocarloswork
2 years, 1 month agoiSnover
2 years, 2 months agoEmilioDeBaku
3 years, 5 months agoronen
4 years ago