Page 1 of 1

About Question enthuware.ocpjp.v7.2.1235 :

Posted: Wed Nov 27, 2013 10:50 am
by muttley
You want to execute a task that returns a result without blocking. Which of the following classes from java.util.concurrent package will be required to achieve this?
Callable, ExecutorService and Future are not classes.

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

Posted: Wed Nov 27, 2013 9:55 pm
by admin
While it is true that these are interfaces, it is common practice to call both (interface and class) as class when the difference is irrelevant or is not to be "revealed" for the point in discussion. After all, there is a "class" file with extension .class, not .interface :)


HTH,
Paul.

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

Posted: Fri Jun 26, 2015 10:27 am
by Alexey Berezkin
The common word correctly addressing both classes and interfaces is type. BTW, it may be also used for enums and primitive types, if you want to include them into a question :)

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

Posted: Wed Jul 22, 2015 10:46 am
by colmkav
Alexey Berezkin wrote:The common word correctly addressing both classes and interfaces is type. BTW, it may be also used for enums and primitive types, if you want to include them into a question :)
That's ridiculous. Some questions you will get wrong if you use this interpretation that an interface is a class. Is the exam still giving such incorrect questions?

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

Posted: Wed Jul 22, 2015 11:43 am
by admin
We have seen candidates getting questions that are somewhat vague or ambiguous. That is why we have included such questions. It is very easy for us to remove or alter such questions than to be at the receiving end of anger from our customers but then we will not be able to make the reader aware of such issues that they may face in the exam.

So our suggestion is to not read too much into the statement and rely on common sense.

HTH,
Paul.

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

Posted: Sun Jan 24, 2016 5:43 pm
by toolforger
Common sense won't help. Here "classes" is supposed to include interfaces, in other questions, it is supposed to exclude them.
I don't know whether that inconsistency is in the exam. Is there a possibility that people report inaccurate information from their exam experience?

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

Posted: Sun Jan 24, 2016 9:53 pm
by admin
It is possible that some information received from test takers is inaccurate. But at the same time, it is also true that there are such inaccuracies in the exam.

HTH,
Paul.

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

Posted: Fri Feb 12, 2016 3:56 am
by Nisim123
Please excuse me for the this question that might sound trivial for some of you,
but the way the question is asked :
You want to execute a task that returns a result without blocking.........
So by saying without blocking what do they actually mean?
I suppose it does not mean simply waiting for a task to end until we start the second one...??? :?

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

Posted: Fri Feb 12, 2016 4:15 am
by toolforger
"Blocking" means "stopping execution to wait for some other process to produce some kind of a result". Often I/O, in a multithreading context it would be waiting for another thread to e.g. terminate, or deliver some data.

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

Posted: Fri Feb 12, 2016 4:38 am
by Nisim123
Thanks tooforger, so I realize that my assumption was not so far from truth,
BTW where did you get the definition of the term blocking ? since i went through the ks&&bb guide
chapter on concurrency and didn't find it there.... :shock:

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

Posted: Fri Feb 12, 2016 4:57 am
by toolforger
It's a general IT term. I first read it in descriptons of Unix system calls.

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

Posted: Tue Mar 29, 2016 3:43 pm
by doziransky
Hi,

So I'm a bit confused about something.

I have always understood that runnables don't return anything while callables do but then I went into the API documentation for ExecutorService today and saw this:

<T> Future<T> submit(Runnable task,
T result)
Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.
Parameters:
task - the task to submit
result - the result to return
Returns:
a Future representing pending completion of the task
Throws:
RejectedExecutionException - if the task cannot be scheduled for execution
NullPointerException - if the task is null

If runnables never return anything then why is this method in the API?

Thanks

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

Posted: Wed Mar 30, 2016 2:10 am
by toolforger
result is passed in to submit() and returned in the Future when the Runnable is finished.
That's useful if the Runnable modifies result.
It is also useful if you need to pass a Future into some API, already have the result ready but don't want to have it processed before the Runnable is finished.

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

Posted: Sat Nov 12, 2016 7:47 pm
by Sai Divya sree
I read in K&B book,
Callable<Integer> c= new Callable();
Future<Integer> f= ex.submit(c);
try{
Integer v=f.get(); //blocks until done
System.out.println(..);
}
catch(InterruptedException| ExecutionException ex){
System.out.println(..)
}
It says:
Interrupted Exception:Raised when the thread calling the Future's get() method is interrupted before the result can be returned.
Now my question is should the get() method always placed inside the try/catch or throws exception mentioned.Am I correct?

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

Posted: Sat Nov 12, 2016 10:28 pm
by admin
Well, InterruptedException is a checked exception so you have to either put the call to get in a try catch or declare the exception in throws clause the method. This is same as for any other checked exception.
-Paul.

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

Posted: Mon Jan 02, 2017 3:30 pm
by jagoneye
admin wrote:We have seen candidates getting questions that are somewhat vague or ambiguous. That is why we have included such questions. It is very easy for us to remove or alter such questions than to be at the receiving end of anger from our customers but then we will not be able to make the reader aware of such issues that they may face in the exam.

So our suggestion is to not read too much into the statement and rely on common sense.

HTH,
Paul.
I have huge respect for this! I hope all the hard work of you guys as well as me preparing for this monster test pays off! :D