Which two can be results? (Choose two.)

Given:

6. public class Threads2 implements Runnable {
7.
8. public void run() {
9. System.out.println(“run.”);
10. throw new RuntimeException(“Problem”);
11. }
12. public static void main(String[] args) {
13. Thread t = new Thread(new Threads2());
14. t.start();
15. System.out.println(“End of method.”);
16. }
17. }

Which two can be results? (Choose two.)

Given:

6. public class Threads2 implements Runnable {
7.
8. public void run() {
9. System.out.println(“run.”);
10. throw new RuntimeException(“Problem”);
11. }
12. public static void main(String[] args) {
13. Thread t = new Thread(new Threads2());
14. t.start();
15. System.out.println(“End of method.”);
16. }
17. }

Which two can be results? (Choose two.)

A.
java.lang.RuntimeException: Problem

B.
run.
java.lang.RuntimeException: Problem

C.
End of method.
java.lang.RuntimeException: Problem

D.
End of method.
run.
java.lang.RuntimeException: Problem

E.
run.
java.lang.RuntimeException: Problem
End of method.

Explanation:
D:
End of method.
run.
Exception in thread “Thread-0” java.lang.RuntimeException: Problem
at Threads2.run(Threads2.java:5)
at java.lang.Thread.run(Unknown Source)

E:
run.
Exception in thread “Thread-0” java.lang.RuntimeException: Problem
at Threads2.run(Threads2.java:5)
at java.lang.Thread.run(Unknown Source)
End of method.



Leave a Reply 0

Your email address will not be published. Required fields are marked *