Checking an override's exception declaration

A Java file-export component declares a method with a checked exception:


Java
class Exporter {
    public void export() throws IOException { }
}


Each table row proposes a method declaration in a separate direct subclass of Exporter. Every candidate has an empty body and an @Override annotation. All named exception classes are correctly imported.


Use these relationships: FileNotFoundException extends IOException; Exception is a superclass of IOException; SQLException is not a subclass of IOException; and IllegalStateException is unchecked.


Enter yes if the candidate compiles as an override, or no if its exception declaration prevents compilation.

Candidate declarationCompiles (yes/no)
public void export()
public void export() throws IOException
public void export() throws FileNotFoundException
public void export() throws Exception
public void export() throws SQLException
public void export() throws IllegalStateException

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Method Overriding Questions: