• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

double in john meyers exam

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I have tow doubles in john meyers' exam, please help me,

1) one question was about Priority Queue, given


answer was "hi followed by ConcuttentAccessException",but when I ran this code it did not give me any Exception. How come ?
2) second was drag and drop question,given
List < ? & gt; = new ArrayList< ? & gt;();
answer was it did not give any compile time error, but when i type this code ,it gave me compile time error that < ? & gt can not be resolved.. !!??

Please clarify my doubles
Thanks

[ July 10, 2007: Message edited by: Bharat Makwana ]
[ July 10, 2007: Message edited by: Bharat Makwana ]
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is double here in John Meyer's exam??
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bharat Makwana:
answer was "hi followed by ConcuttentAccessException",but when I ran this code it did not give me any Exception. How come ?

Did you mean ConcurrentModificationException? If yes, then you need one more element in the queue to actually get it.

Please note: The occurence of ConcurrentModificationException is dependant on the iterator implementation. So it's easy to say when it may occur, but you don't know whether it occurs until you try it.
 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Manfred Klug:
Did you mean ConcurrentModificationException? If yes, then you need one more element in the queue to actually get it.



yes, there were 3 elements in that question,but i ran my code with only two elements

and i did not get any exception, can you please elaborate more on this question when and how I may get exception
Thanks for reply
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bharat Makwana:
can you please elaborate more on this question when and how I may get exception

You may get the exception if someone (same or other thread) modifies the collection while you iterate over it. In your example, the loop uses an iterator, and you modify the list via the call of poll (you remove one element). But as you have seen, it depends on the implementation of the collection and the iterator whether you actually get the exception.
 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Manfred Klug
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic