Page 1 of 1
About Question enthuware.ocpjp.ii.v11.2.3312 :
Posted: Tue Jun 09, 2020 2:40 am
by lexlexych
Code: Select all
List<? extends Booby> bV = null;
List<? super Dooby> dV = null;
dV.add(new Dooby(){ }); // -> NullPointerException
bV.add(new Dooby(){ }); // -> NullPointerException
How can
dV.add(new Dooby(){ }); be the correct answer?
Re: About Question enthuware.ocpjp.ii.v11.2.3312 :
Posted: Tue Jun 09, 2020 2:51 am
by admin
You are right. It has been updated as follows to make it clear:
List<? extends Booby> bV = //code for initialization
List<? super Dooby> dV = //code for initialization
thank you for your feedback!