Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Question about generic overriding. Blow up brain.

 
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question not from mock test. It arise when i read Mala Gupta book and think about how exam may trick me.
Why MapLegendGeneric cosider that it corectly override MyMap??? try code yourself, pay note that MapLegendGeneric<V, K> change position of <K, V> when implements MyMap<K, V>
Why MapLegendGeneric cosider that it corectly override (note using @Override to check!) MyMap???

also just for test i make some changes:

 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried it myself, but I don't think that the order of type parameters in



is significant. In other words I think that the two V's are matched and the two K's are matched. A test of this hypothesis:



should produce some error messages.
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic