subject

Consider the following code (assume that comments are replaced with real code that works as speciied): public class TestExceptions {
static void e() {
// Might cause any of the following unchecked exceptions to be
// thrown:
// Ex1, Ex2, Ex3, Ex4
}
static void April() { try {
e();
} catch (Ex1 ex) { System. out. println("April caught Ex1");
}
}
static void March() {
try {
April();
} catch (Ex2 ex) { System. out. println("March caught Ex2");
// now cause exception Ex1 to be thrown
}
}
static void February() {
try {
March();
} catch (Ex1 ex) { System. out. println("February caught Ex1");
} catch (Ex3 ex) { System. out. println("February caught Ex3");
}
}
static void a() { try {
February();
} catch (Ex4 ex) {
System. out. println("January caught Ex4");

// now cause exception Ex1 to be thrown
} catch (Ex1 ex) { System. out. println("January caught Ex1");
}
}
public static void main(String[] args) { January();
}
}

Assume now that this program is run four times. The first time, method throws exception Ex1, the second time, it throws exception Ex2, etc.

What are the results of the four runs (a or b)?

a.
1. The program prints: April caught Ex1
2. The program prints: March caught Ex2 February caught Ex1
3. The program prints: February caught Ex3
4. The program prints: January caught Ex4
And execution stops due to an uncaught exception Ex1 thrown in
main()

b.
1. The program prints: April caught Ex3
2. The program prints: March caught Ex2 February caught Ex2
3. The program prints: March caught Ex3
4. The program prints: January caught Ex4
And execution stops due to an uncaught exception Ex1 thrown in
main()

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:30, morganwendel126
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. centurion: a commander in the army of ancient rome. keyword: picture:
Answers: 2
image
Computers and Technology, 23.06.2019 06:30, arguellesjavier15
Who can provide you with a new password when you have forgotten your old one? your provide you with a new password in case you forget your old one.
Answers: 3
image
Computers and Technology, 24.06.2019 10:00, shrafe
Which two technologies support the building of single-page applications?
Answers: 2
image
Computers and Technology, 24.06.2019 11:00, asiaosterling
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
You know the right answer?
Consider the following code (assume that comments are replaced with real code that works as speciied...

Questions in other subjects:

Konu
Biology, 05.04.2020 21:21
Konu
Mathematics, 05.04.2020 21:22
Konu
Mathematics, 05.04.2020 21:23