File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mock question on enhanced for Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Mock question on enhanced for" Watch "Mock question on enhanced for" New topic

Mock question on enhanced for

Dariusz Kordonski
Ranch Hand

Joined: Jul 11, 2008
Posts: 49
I came across a mock question for SCJP 1.5 from JavaBeat Mock exams ('Language features', Q6):
'Which of the following statements are true about the new enhanced for loop?'
One of the answers is:
'The enhanced for loop eliminates the need for Iterator objects'.
And it is said to be one of correct choices. Now I would argue that the need for iterators is not eliminated entirely with introduction of the enhanced for - e.g. let's take code scenarios, when we have to remove objects from collection during iteration. It is not possible (or at least not safe) using the enhanced for.

Do you agree that such formulation is at least a bit ambiguous? Can I expect this kind of questions / answer choices at the real SCJP?
Jamie MacDonald

Joined: May 17, 2008
Posts: 20
Hmmm...well technically the statement is true because it is true in some cases, but you are right--it is poorly worded. Trying to apply a programmer's need for precision to the English language is always fraught with peril.
I agree. Here's the link:
subject: Mock question on enhanced for
It's not a secret anymore!