This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock question on enhanced for

 
Dariusz Kordonski
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic