About Question enthuware.ocpjp.v7.2.1711 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Wisevolk
Posts: 33
Joined: Thu Jul 18, 2013 6:06 pm
Contact:

About Question enthuware.ocpjp.v7.2.1711 :

Post by Wisevolk »

Hello,
If we can say that priority thread are not guaranteed, what about the first answer even if there is the most tinies probabilities ?

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

Well, can you show a situation when any other output except the one mentioned in option 3 is possible?

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Wisevolk
Posts: 33
Joined: Thu Jul 18, 2013 6:06 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by Wisevolk »

I can't show a specific situation because of thread unpredictability, but what I say is if the "first" thread in the code is not run before the second finish the first answer is right to ?

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

That is not a valid argument. You are misunderstanding what thread unpredictability means. Thread Unpredictability does not mean that just about any output can occur. All the output can be predicted, but which output will occur when is what is unpredictable.

If you can show a situation that is theoretically possible, then you can use the unpredictability argument to explain why that output did not occur when you ran program. Thread unpredictability does not prevent you from determining a situation where the output that you are claiming will occur.


HTH,
Paul.
If you like our products and services, please help us by posting your review here.

DesRenthuware
Posts: 32
Joined: Wed Aug 28, 2013 6:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by DesRenthuware »

Hi.

Also a bit confused by this... if this was running on a Unix like system and both threads could be forced to wait, while a higher priority thread ran under the OS. Once the higher priority thread ended, the order in which these threads execute is unknown. "Thread 2 (the printer)" could be executed before "Thread 1 (the remover)", resulting in the first answer being correct?

Am I completely missing the boat?

Cheers

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

The order in which the two threads will run is unknown even without any other higher priority thread in the picture. But that will still not generate the output mentioned in option 3. So option 1 is still wrong.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

DesRenthuware
Posts: 32
Joined: Wed Aug 28, 2013 6:12 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by DesRenthuware »

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'?

I (and I suspect Wisevolk) were interpreting the question (and answer 3 in particular) as:

It can print any combination except combinations that contain a || b in conjunction with c (on the assumption that a and b had already been removed).

Cheers

gk_javauser
Posts: 9
Joined: Sun Jul 19, 2015 6:31 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by gk_javauser »

I would like to understand this as well ,why choice 1 is not a valid answer.

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

Please read the discussion above.
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

I have confirmed that it has been fixed in v 1.94
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

boyonsea
Posts: 16
Joined: Fri Sep 04, 2015 5:06 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by boyonsea »

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

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

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.

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

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'?
Yes, that is correct.
If you like our products and services, please help us by posting your review here.

jagoneye
Posts: 97
Joined: Wed Dec 28, 2016 9:00 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by jagoneye »

The wordings of the answer options are difficult to understand. But the right answer is indeed the third option.

rohitbe
Posts: 5
Joined: Fri Mar 10, 2017 12:25 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by rohitbe »

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)

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

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."
If you like our products and services, please help us by posting your review here.

rohitbe
Posts: 5
Joined: Fri Mar 10, 2017 12:25 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by rohitbe »

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.

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by admin »

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.

rohitbe
Posts: 5
Joined: Fri Mar 10, 2017 12:25 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1711 :

Post by rohitbe »

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. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests