• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Sun Practice Exam has incorrect answer?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sun appears to have the wrong answer for the following question from the first of its $75 practice exams:

For a single synchronized instance method with no wait() call involved, which two statements are true? (Choose two.)

A
The object lock is applied to the object containing the method.
B
Only synchronized methods can be called from within this method.
C
All methods accessed from within this method are inherently thread safe.
D
Only one thread of execution will be permitted to execute the method at one time.
E
Concurrent threads will be unable to execute other non synchronized instance methods in the same object while the synchronized method is being executed.


The given answer was A and D. However anyone who reads closely will notice that D is clearly false as written; more than one thread may execute the method on different instances of the class at the same time. Furthermore C as written is extremely vague (is it talking about this object only or other objects, what does it mean by "thread safe?) but seems to be true; from within a synchronized method if a non-synchronized method is called the thread will still hold the lock.

So based on the answer I know what they meant but clearly the answer is either wrong or it was a very poorly written question. Does anyone know if the actual exam has such poor questions? Are the practice exams representative of the actual one?
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C is clearly false. Even though the method you are in is syncronized, other methods that you call that are not can be called by other threads. Doesn't matter if it is this object or other objects.

D is clearly true. I don't know how you can say a syncronized method can used by more than one thread at a time. If that was the case what would be the point of syncronization?

I don't see a problem with the question.
 
Paul Caplan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> D is clearly true. I don't know how you can say a syncronized method can
> used by more than one thread at a time. If that was the case what would
> be the point of syncronization?

For instance methods, synchronization is based on an object, not a class. If there are two objects then there can be 2 threads in the method.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read the question? 'For a single synchronized instance method'

If there were two Objects that would be two synchronized instance methods.
 
Paul Caplan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An "instance method" simply means its not static. A "single" instance method means one method. Now even if there is only one method, there can stil be two objects.

Did YOU read the question? Please don't talk down to me any more. The rules say "be nice".
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

I really think Steve is trying to help. As with any post it is easy to mis-interpret someone's tone. It happens all the time. He is just trying to explain why he feels that the question and answer is correct. Which I agree with him on his assessment.

When I read into his replies, I don't feel that he is trying to be condenscending towards you.

Your points are also accurate, in that if there were two objects, and two different callers on different objects calling that method, each object will be locked by the different callers and both execute. I think the question is at a higher level than direct implementations. So as a rule D is true. At this point it isn't about how many instances there are. And if you look at the sentence for D "Only one thread of exection will be permitted to execute the method at one time" Then the "the method" needs to be defined because if there are two instances then there are two methods, one in one instance and one in the other, so if that is the case then D is true again.

I hope this helps clarify whtat Steve was trying to say.

Thanks

Mark
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Steven]: If there were two Objects that would be two synchronized instance methods.

I certainly wouldn't describe it that way. I'd say two threads are calling the same single method using two different instances. I agree with Paul that D is untrue.

As for C, I agree with Steven that it's definitely false, for the reasons he gave.

[Paul]: Does anyone know if the actual exam has such poor questions? Are the practice exams representative of the actual one?

Well, we hope not. The real exam is much more rigorously reviewed than the practice exams. It's possible that errors and ambiguities got in anyway. I haven't seen the practice exams, but based on this one question I'd say you can expect the real exam to be better.
[ March 03, 2005: Message edited by: Jim Yingst ]
 
Paul Caplan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone, I shouldn't really worry about it I was just annoyed because I paid 75 bucks to get that exam and had to deal with one of the worst online shopping applications I have ever seen (which is a bit ironic i think ...) so I was a little mad at Sun. But ambiguity is inherent to any language (certainly English), I'll deal
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Caplan:
Please don't talk down to me any more. The rules say "be nice".



I'm sorry for my tone, I didn't mean to be talking down and I will try to be careful about that in the future.

As for one vs two instance methods, I think that my answer there was badly worded. As the answer D is refering to 'the method' it seems to me that it is referring to a single instance object, and the method of that object.
 
Paul Caplan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem Steve my excuse is I'm just stressed out from studying
 
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe that D is true. I think if you look at a question such as this with multiple answers, you also have to consider the choice answers. Some answers to this question pertains to only one instance, so the rest must also do the same. So that means that the question also pertains to only one instance as well.
[ March 03, 2005: Message edited by: Alton Hernandez ]
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Alton]: Some answers to this question pertains to only one instance, so the rest must also do the same.

I don't agree at all. When two answers have different wording, the differences in wording are important. That's what makes it possible to choose one answer instead of another. You can't assume that something stated in answer (E) should be part of your assumptions for answer (D). Down that road lies madness.

[Steven]: As the answer D is refering to 'the method' it seems to me that it is referring to a single instance object, and the method of that object.

Well, here's a class I wrote:

I would say that this class has one method. It is a single synchronized instance method. I can make other statements about "the method", such as "the method bar() doesn't really do anything." I'm quite happy thinking of this as a single method. If I then create five different Foo instances and call bar() once with each instance, I would not feel compelled to go back and revise my previous statement to say that class Foo now has five methods. It doesn't. It has eactly one method, no matter how many times that method gets called. Now, if you've heard me talk about "the instance method bar()", should you assume that I would never ever call this method using two different instances, or from two different threads? I don't think so. Referring to a method using "the" does not imply anything at all about the number of instances that might exist.
[ March 03, 2005: Message edited by: Jim Yingst ]
 
Paul Caplan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad someone else agrees with me The second sun practice exam has a similar question but specifically states "given one instance", which is much more nicer of them.
 
Alton Hernandez
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jim Yingst:
[Alton]: Some answers to this question pertains to only one instance, so the rest must also do the same.

I don't agree at all. When two answers have different wording, the differences in wording are important. That's what makes it possible to choose one answer instead of another. You can't assume that something stated in answer (E) should be part of your assumptions for answer (D). Down that road lies madness.
[ March 03, 2005: Message edited by: Jim Yingst ]



Granted that the question is ambigous and should not be asked in an exam. But face with this situation, where an examinee has no other choice but to answer, he has to understand the question on the context of the answers i.e. the consequent(answer) must be identical to the antecedent(question).

(A) and (E) are specific about a reference to a single instance, because of the phrases the object and same object. Although the rest are not talking about a single object, they are also not specific about more than one as well. So I will only assume the most specific and that the author is not changing context.

So for example, if I ask a question like this:


Which of the following I don't like:

1) Italian Food
2) Mexican
3) Japanese Food
4) Chinese


You would assume that question is about food, and that in options (2) and (4) I was not talking about Mexican and Chinese people?

[ March 03, 2005: Message edited by: Alton Hernandez ]
[ March 03, 2005: Message edited by: Alton Hernandez ]
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, with your food question, the difference is that there's really no good way to answer "do you like Chinese?" without some more context. Chinese food? Chinese people? Chinese language? I need that info in order to answer, and the question did not provide the info in any clear manner, and I am forced to guess. So in that case, I'll go ahead and take the context from the other options, while mentally cursing the question author for being unable to form a better question. I would have little confidence in this answer, because at this point I don't trust the question author to be competent. (No offense to you of course; this is hypothetical.) I'm just making my best guess.

In contrast, for the practice exam question, option D is clear enough already. It has a definite answer (false) based on the information provided. I don't need to import context from other answers - good, because that's a very questionable thing to have to do. Now, it turns out that in this case, the author did not intend the question in the way I interpreted it. (Based on the given answer, A and D.) So OK, now I would say that the author is simply wrong, and evidently this practice exam did not go through rigorous screening from Sun. The difference is that for the Chinese question, the incompetence of the author was evident immediately (since it was obvious more info was needed) while for the practice exam question, the author's incompetence was better hidden.

OK, "incompetence" is a little harsh for both authors; call it carelessness. Either way, the question was broken. I prefer to assume a question means exactly what it says, unless and until I see evidence that the question can't be interpreted that way. Now if I detect that a question is broken, I may be able to make a good guess as to what the author really meant. In this case, an obviously broken question (like "do you like Chinese?") is better than a subtly broken question (like option D). Still, if I don't see any obvious signs a question is broken, I prefer to assume the author knows what they're doing, rather than worry over all the possible ways the author might have subtly screwed it up.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider this question:

Which of the following are true?

(A) Coyotes are mammals.
(B) Koalas are mammals that live in Australia.
(C) Alligators are mammals.
(D) Penguins are birds that live in Australia.

Should we assume that "that live in Australia" should be applied to option A and C? Since after all, those options never specified whether they were in Australia or not? Should we assume that the most specific context (in Australia) should be applied to all answers? I don't think so. To me, A is obviously true, and C is obviously false; those answers are clear without trying to import context from other answers.
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just don't see how "single instance method", in common Java usage, means the same as "single method instance".

Physically, the bytecode for a method is shared among all class instances and the method's local variables and workspaces in the stack frame are unique to a method invocation (think recursive), not to a class instance.

A bigger issue is that there is no effective way to complain about errors and ambiguities in the live test. You are not allowed to take away any notes and the Prometrics employees can only put your comments into a daily report that may not even get to Sun. There is no feedback so who knows. I found three harmless but real errors in my live SCJP and I wasn't even looking.
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic