Question

Question 2 What happens in a method if an exception is thrown in a trylblock and there is NO MATCHING catch() block? The meth
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer##

The correct answer is option 1

That is:The method throws the exception to its caller, exactly if there were no try{} block

If the exception thrown in a try block and if the there is no matching catch block for it, the catch block rethrows it then the program control passes to the enclosed tryblock and the try block throws to the caller.

Add a comment
Know the answer?
Add Answer to:
Question 2 What happens in a method if an exception is thrown in a trylblock and...
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
  • What happens when an exception is thrown inside a try block? a. The exception is rethrown...

    What happens when an exception is thrown inside a try block? a. The exception is rethrown to the calling function. b. Control is transferred to the first statement in the catch block. c. An error message is displayed in the browser’s console window. d. The function returns a value of undefined.

  • 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...

  • 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?

  • 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...

  • QUESTION 1 If an exception is thrown None listed all listed execution terminates if there is...

    QUESTION 1 If an exception is thrown None listed all listed execution terminates if there is no catch block handling the same data type as the exception thrown execution continues if the catch block handles the same data type as the exception thrown 10 points    QUESTION 2 An exception is handled using an if-else statement an assignment statement a loop statement a try-catch block 10 points    QUESTION 3 In program 9.4, what is the data type being thrown?...

  • What are the results of the program as written? What results would the program produce if...

    What are the results of the program as written? What results would the program produce if you changed the value of a from 0 to 3? ************************************************************************************* * Program Summary:    *   This code includes simple try/catch (exception handling) functionality. * We put some arithmetic code into a "try" block so that we can "catch" an exception * that is thrown during the course working through the arithmetic. * We need to know specifically what kind of exception we intend...

  • Exception handling is a powerful tool used to help programmers understand exception errors. This tool separates...

    Exception handling is a powerful tool used to help programmers understand exception errors. This tool separates the error handling routine from the rest of the code. In this application, you practice handling exception errors. You use sample code that was purposefully designed to generate an exception error, and then you modify the code so that it handles the errors more gracefully. For this Assignment, submit the following program: The following code causes an exception error: import java.io.BufferedReader; import java.io.IOException; import...

  • import java.util.Scanner; import java.io.File; public class Exception2 {        public static void main(String[] args) {              ...

    import java.util.Scanner; import java.io.File; public class Exception2 {        public static void main(String[] args) {               int total = 0;               int num = 0;               File myFile = null;               Scanner inputFile = null;               myFile = new File("inFile.txt");               inputFile = new Scanner(myFile);               while (inputFile.hasNext()) {                      num = inputFile.nextInt();                      total += num;               }               System.out.println("The total value is " + total);        } } /* In the first program, the Scanner may throw an...

  • Placing Exception Handlers File ParseInts.java contains a program that does the following: Prompts for and reads...

    Placing Exception Handlers File ParseInts.java contains a program that does the following: Prompts for and reads in a line of input Uses a second Scanner to take the input line one token at a time and parses an integer from each token as it is extracted. Sums the integers. Prints the sum. Save ParseInts to your directory and compile and run it. If you give it the input 10 20 30 40 it should print The sum of the integers...

  • (I don't need code for this question I only need explanation how to solve the question.)...

    (I don't need code for this question I only need explanation how to solve the question.) The following code causes an exception error: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class Ex02 {     public static void main(String[] args) throws IOException {         BufferedReader userInput = new BufferedReader             (new InputStreamReader(System.in));         ArrayList<String> myArr = new ArrayList<String>();         myArr.add("Zero");         myArr.add("One");         myArr.add("Two");         myArr.add("Three");                 System.out.println(myArr.get(7));                     } } Starting with this provided code,...

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