Return to site

JAVA CERTIFICATION QUESTION: Abstract methods of concrete classes in Java

· java

All the abstract methods inherited by a concrete class must have concrete implementations, or the code cannot compile.

Given the following code:

interface Text {
    default String getContent() { return "Blank"; }
    void setContent(String txt);
    void spellCheck() throws Exception;
}

abstract class Prose {
    public abstract void setAuthor(String name);
    public void spellCheck() {
        System.out.print("Do generic prose spellcheck");
    }
}

class Novel extends Prose implements Text {
  // line n1
}

 

Which fragments added simultaneously at line n1 allow the following two lines of code to compile and run? Choose two.

Novel n = new Novel();

n.spellCheck();

 

A. public void spellCheck() throws Exception { }

B. String getContent() { return "Novel"; }

C. public String getContent() { return "Novel"; }

D. public void setAuthor(String a) { }

E. public void setContent(String txt) { }

 

 

 

·Ǝ puɐ ꓷ suoᴉʇdo ǝɹɐ sɹǝʍsuɐ ʇɔǝɹɹoɔ ǝɥꓕ