About Question enthuware.ocpjp.v7.2.1711 :
Moderator: admin
-
- Posts: 16
- Joined: Fri Sep 04, 2015 5:06 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
re read the explanation multiple times, still dont understand why option 1 is incorrect.
if thread 2 starts before thread 1, it will print a,b,c or b,a,c or any other combo since the order is not known
Read discussion above is also misleading, since DesRenthuware explicit suggestion "a, || b, || a, b, || b, a " was not confirmed.
Thanks
if thread 2 starts before thread 1, it will print a,b,c or b,a,c or any other combo since the order is not known
Read discussion above is also misleading, since DesRenthuware explicit suggestion "a, || b, || a, b, || b, a " was not confirmed.
Thanks
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Can the code ever print just a? or just b? or a, b? or b, a? The answer is no. Hence, option 1, which says "It may print any combination of the keys." cannot be correct. Right?
If you like our products and services, please help us by posting your review here.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Yes, that is correct.DesRenthuware wrote:Hmmm....
Completely misunderstood the answer to three. What you are saying is, it could print:
a, b, c, || b, c, || a, c, etc.
but never
a, || b, || a, b, || b, a
by themselves without 'c'?
If you like our products and services, please help us by posting your review here.
-
- Posts: 97
- Joined: Wed Dec 28, 2016 9:00 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
The wordings of the answer options are difficult to understand. But the right answer is indeed the third option.
-
- Posts: 5
- Joined: Fri Mar 10, 2017 12:25 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Highly unlikely for the first thread to not get a chance to run before the second thread actually starts running but possible(Anyways, cannot be proved theoretically).
Then this theoretical principle should be applied for the explanation of your question viewtopic.php?f=2&t=1812
Can you prove here theoretically that main thread will not call 'a.interrupt()' while the other thread is sleeping? (condition - you are not allowed to change the code in the question as with the above case)
Then this theoretical principle should be applied for the explanation of your question viewtopic.php?f=2&t=1812
Can you prove here theoretically that main thread will not call 'a.interrupt()' while the other thread is sleeping? (condition - you are not allowed to change the code in the question as with the above case)
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Did you read the explanation for question 2.1324?
It says that same thing that you are saying, "Even though the thread is sleeping for 10 seconds and it is very probable that the main thread will execute and call a.interrupt() (which will cause the sleeping thread to receive an InterruptedException), this behavior cannot be guaranteed. It is possible, even though highly unlikely, that the sleeping thread will complete its 10 seconds sleep and the main thread may not get a chance to run and call a.interrupt() in those 10 seconds. In this case there won't be any exception."
It says that same thing that you are saying, "Even though the thread is sleeping for 10 seconds and it is very probable that the main thread will execute and call a.interrupt() (which will cause the sleeping thread to receive an InterruptedException), this behavior cannot be guaranteed. It is possible, even though highly unlikely, that the sleeping thread will complete its 10 seconds sleep and the main thread may not get a chance to run and call a.interrupt() in those 10 seconds. In this case there won't be any exception."
If you like our products and services, please help us by posting your review here.
-
- Posts: 5
- Joined: Fri Mar 10, 2017 12:25 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Yes, I have read it and understood it the way you explained it. It's theoretically not possible to explain that main thread will not be calling 'a.interrupt()' while the other Thread is sleeping for 10 seconds. I agree, there is 99% possibility of InterruptedException being thrown but 1% of not being thrown.
IF you yourself are accepting a possibility of a highly unlikely situation that can't be proved theoretically, then why not here in this question.
Same thing goes here for this question - There is 99% possibility that second thread started by main will be executed after first but 1% possibility that the first thread(triggered by main) may be kept on hold by OS scheduler due to some reason while the second thread(also triggered by main) has started running.
For this question, I agree, it is very probable that the main thread will execute the first Iterator thread before starting with the second but it is not guaranteed. Like, main thread has started the first iterator thread but due to some reason, its run() is still not called while the second iterator thread had been started by main in that duration and whose run() is executed before first.
IF you yourself are accepting a possibility of a highly unlikely situation that can't be proved theoretically, then why not here in this question.
Same thing goes here for this question - There is 99% possibility that second thread started by main will be executed after first but 1% possibility that the first thread(triggered by main) may be kept on hold by OS scheduler due to some reason while the second thread(also triggered by main) has started running.
For this question, I agree, it is very probable that the main thread will execute the first Iterator thread before starting with the second but it is not guaranteed. Like, main thread has started the first iterator thread but due to some reason, its run() is still not called while the second iterator thread had been started by main in that duration and whose run() is executed before first.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Yes, the same goes for this question as well. It is possible that the second thread may get to execute first. But so what? How does that change the answer?
If you like our products and services, please help us by posting your review here.
-
- Posts: 5
- Joined: Fri Mar 10, 2017 12:25 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1711 :
Got it.
Anyways, with either case, it's never gonna exclude 'c' from the combination. So combinations without 'c' are never possible.
Sorry misinterpreted the answer options.
Anyways, with either case, it's never gonna exclude 'c' from the combination. So combinations without 'c' are never possible.
Sorry misinterpreted the answer options.
Who is online
Users browsing this forum: Google [Bot] and 106 guests