What is the result?

Given:
11. Runnable r = new Runnable() {
12. public void run() {
13. System.out.print(“Cat”);
14. }
15. };
16. Thread t = new Thread(r) {
17. public void run() {
18. System.out.print(“Dog”);
19. }
20. };
21. t.start();
What is the result?

Given:
11. Runnable r = new Runnable() {
12. public void run() {
13. System.out.print(“Cat”);
14. }
15. };
16. Thread t = new Thread(r) {
17. public void run() {
18. System.out.print(“Dog”);
19. }
20. };
21. t.start();
What is the result?

A.
An exception is thrown at runtime.

B.
The code runs with no output.

C.
Dog

D.
Compilation fails.

E.
Cat



Leave a Reply 0

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