• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Mock question on enhanced for

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic