It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generics question--Bit complicated?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generics question--Bit complicated??" Watch "Generics question--Bit complicated??" New topic
Author

Generics question--Bit complicated??

prashanth kumar
Ranch Hand

Joined: Mar 22, 2004
Posts: 162
Hello All,
I have this question regarding generics.
Can anybody explain me why the options 4 and 6[i know abt this option]are correct?

Many Thanks



SCJP1.5(86%)<br />SCWCD1.4(95%)<br />SCBCD1.3(92%)<br />IBM 252
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Option 4 is correct because if you removed lines 2 and 3, you are just adding a new entry to the map containing a String for key, and ArrayList for value.

Option 6 will work because there is no requirement in a general map that the keys be mutually Comparable.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Generics question--Bit complicated??