Ask Question
10 October, 16:02

If the code in a method can potentially throw a checked exception, then that method must:

a.) handle the exception

b.) have a throws clause listed in the method header

c.) neither handle the exception nor have a throws clause listed in the method header

d.) either handle the exception or have a throws clause listed in the method header

+1
Answers (1)
  1. 10 October, 17:19
    0
    d.) either handle the exception or have a throws clause listed in the method header

    Explanation:

    A checked exception that can be thrown in a method, necessarily needs to be handled in the method in one of the two ways:

    Handle the exception in code Have a throws clause in method header

    For example, let us see both:

    a)

    public void mymethod () {

    / / Exception handling using try/catch block

    try{

    }

    catch (IOException e) {

    }

    }

    b)

    public void mymethod () throws IOException{

    / / Exception in the throws clause

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “If the code in a method can potentially throw a checked exception, then that method must: a.) handle the exception b.) have a throws clause ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers