• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Problem from K&B practice exam

 
Aashu Mahajan
Ranch Hand
Posts: 114
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source : OCP java SE programmer Practice Exam.(Q.31)

Which are true? (Choose all that apply.)
A. Compilation fails.
B. After throwing error(s), t3 will most likely complete before t4.
C. After throwing error(s), t4 will most likely complete before t3.
D. The code will throw one error and then no more output will be produced.
E. The code will throw two errors and then no more output will be produced.
F. After throwing error(s) it’s difficult to determine whether t3 or t4 will complete first.

Correct Answere : C
I could not understand why option 'E' is not correct because the code will throw two Errors. one error will thrown by "t1" and another error will thrown by "t2".
Please let me know where i am wrong??
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why posting the same question in two different places..
The same question can be found Here also
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have patience for someone to answer this.
 
Aashu Mahajan
Ranch Hand
Posts: 114
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Guys

Actually my first post was written by mistake and while writing my doubts i didn't knew which forum i am using but when i return to forum then i came to know i posted in a wrong forum then i try to remove post but i did't find any option for deleting post.
Then i did repost my question on the correct forum.
 
Asad Zubair
Ranch Hand
Posts: 44
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option E is not correct because although there will be 2 errors thrown, it is highly likely (although not guaranteed) that more output will be produced. This is because there is a new thread being started (t3 and t4) just before the error is thrown so they will continue to run and print separately regardless of the errors being thrown by t1 and t2.
 
Aashu Mahajan
Ranch Hand
Posts: 114
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Asad Zubair for your response.

The Option 'E' does mean that after occurring two errors no more output will be produced. But actually after occurring two errors the output still appear on the screen. correct me if i am wrong.


 
T Vergilio
Ranch Hand
Posts: 230
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not C and F?

F. After throwing error(s) it's difficult to determine whether t3 or t4 will complete first.


t3 will most likely finish before t4, but not definitely, therefore it is difficult to determine that.

Determine = know for sure. Right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic