Meaningless Drivel is fun!
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generics question--Bit complicated??" Watch "Generics question--Bit complicated??" New topic

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: 2398
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.
I agree. Here's the link:
subject: Generics question--Bit complicated??
It's not a secret anymore!