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

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

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

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

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

  • please help Question 2 (1 point) Saved Choose the option that best describes what happens when...

    please help Question 2 (1 point) Saved Choose the option that best describes what happens when the bolded println() statement is executed: public class Point { public static void main(String[] args) { Point p 1 = new Point(3, 4); System.out.println(p1); } public int x, y; public Point(int xx, int yy) { x = xx; y = yy; } سی Point inherited a toString() method, which is called internally by println(). This is a compile error - println doesn't know how...

  • Question 10 (3 points) Which of the following statement is not true? There is a recursive...

    Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum (19) is called, summation of all odd numbers less than 19 will be calculated and returned public int sum(int x){ if (x == 0) return 0: else return sum(x-2) + x; The following code segment will throw a testException. This exception has been handled in the way that do nothing but to continue when this exception happens....

  • Moving to another question will save this response. Question 2 What is the operating income for...

    Moving to another question will save this response. Question 2 What is the operating income for 2015? $86,000 74,000 307,000 454,000 101,000 Beginning finished good, 1/1/2015 Ending finished goods, 12/31/2015 Cost of goods sold Sales revenue Operating expenses $34,000 $46,000 $58,000 $73,000 L A Moving to another question will save this response.

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