试题详情
单项选择题 11. public void addStrings(List list) {  12. list.add(”foo”);  13. list.add(”bar”);  14. }  What must you change in this method to compile without warnings?() 

A、 add this code after line 11: list = (List) list;

B、 change lines 12 and 13 to: list.add(”foo”); list.add(”bar”);

C、 change the method signature on line 11 to: public void addStrings(List< extends String> list) {

D、 change the method signature on line 11 to: public void addStrings(List< super String> list) {

E、 No changes are necessary. This method compiles without warnings.

  • D
  • 关注下方微信公众号,在线模考后查看

热门试题