Question

What happens if you invoke a method and it throws a checked exception that it does...

What happens if you invoke a method and it throws a checked exception that it does not catch?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
If checked exception is not caught in the method, then the method should declare that it throws the exception.

For example if a method named m1 throws an IOException but not caught inside the method. 
Then it should declare it throws IOException.
// This method declares that it is throwing an IOException
void m1() throws IOException {
    
}
Add a comment
Know the answer?
Add Answer to:
What happens if you invoke a method and it throws a checked exception that it does...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 2 What happens in a method if an exception is thrown in a trylblock and...

    Question 2 What happens in a method if an exception is thrown in a trylblock and there is NO MATCHING catch() block? The method throws the exception to its caller, exactly as if there were no tryt block. This is not legal, so the program will not compile. The program halts immediately. The program ignores the exception. 0 0 L A Moving to another question will save this response,

  • Exception handling All Exceptions that can be thrown must descend from this Java class: The getMessage(...

    Exception handling All Exceptions that can be thrown must descend from this Java class: The getMessage( ) method is inherited from this class? What are the two broad catagories of Exceptions in Java? If an Exception is not a checked exception it must extend what class? What is the difference between a checked Exception and an unchecked Exception? What are the two options a programmer has when writing code that may cause a checked Exception to be thrown? Can a...

  • if method m1 calls method m2 and method m2 throws and exception method m1 must do...

    if method m1 calls method m2 and method m2 throws and exception method m1 must do one of what two things

  • What is exception propagation? Give an example of a class that contains at least two methods,...

    What is exception propagation? Give an example of a class that contains at least two methods, in which one method calls another. Ensure that the subordinate method will call a predefined Java method that can throw a checked exception. The subordinate method should not catch the exception. Explain how exception propagation will occur in your example.

  • Please answer both questions thanks Question 16 (1 point) Select all of the TRUE statements. A...

    Please answer both questions thanks Question 16 (1 point) Select all of the TRUE statements. A method has at least one return statement. A method has at most one return value. When executing a return statement, the method exits immediately. A method with return value void must print a result. A method can have multiple return statements. Question 17 (1 point) What is the difference between a checked exception and an unchecked exception? A checked exception indicates ndicates an error...

  • the question, this is not running it throws an exception would you help me it is...

    the question, this is not running it throws an exception would you help me it is a java program // why this is not running would you help me public class sample {     public static void main(String[] args){         String str[][] = new String[10]['K'];                 for(int i= 1;i<=10; i++){             for(char j= 'A';j<='J'; j++){                 System.out.print(i +" "+ j);                  str[i][j] = "A";                   System.out.print(" ");                                                   }              System.out.println();                                  }            ...

  • Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the...

    Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the following program? public class Quiz2B { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int i = 0; int y = 2 / i; System.out.println("Welcome to Java"); } catch (RuntimeException ex) { System.out.println("Welcome to Java"); } finally { System.out.println("End of the block"); } } } Question 1 options: The program displays Welcome to Java two times. The program displays Welcome to...

  • In what sense does the MWC model invoke the concept of cooperativity?

    In what sense does the MWC model invoke the concept of cooperativity?

  • Java What does it mean to throw an exception? How does one express throwing an exception...

    Java What does it mean to throw an exception? How does one express throwing an exception in Java? Give one reason to use exceptions instead of these other ways. HTML Editor B IV AA- IE311xx D T 12pt Paragrap

  • 13. A girl throws a ball 20 m vertically into the air. A) How long does...

    13. A girl throws a ball 20 m vertically into the air. A) How long does she have to wait to catch it on the way down? b) How far does it fall in this time? C) what will be its final velocity?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT