I know why answer C is right, but then the question I have is why answer A is wrong?
public List<Integer> getList(){
// why is this answer incorrect ???
About Question enthuware.ocpjp.v21.2.3087 :
Moderator: admin
-
- Posts: 8
- Joined: Sat Aug 02, 2025 11:21 pm
- Contact:
-
- Site Admin
- Posts: 10436
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.3087 :
Because List<Integer> is not a subtype of List<Number>. Go through the rule of covariant returns given in the explanation. It shows two hierarchies of generic types. Read that carefully.
Who is online
Users browsing this forum: No registered users and 84 guests