![](https://csdnimg.cn/release/download_crawler_static/86074753/bg6.jpg)
解析:
� 先看题目, 要求作一个 string 对应到 integer.
� 开始执行已知程序代码. 建构出 nn 之 NumberName 对象, 呼叫 put(), 并给参数
("one", 1 )
� 再呼叫其 getName() 方法
� 再看其要求结果为印出 [one]
� 因此, 该题目的重点放在 NumberName 类别的程序代码
o 依照题意, 并从 put() 方法观察到, 存放 String, 及 int 或是 Integer,
但是从 HashMap 宣告来看, 就只能是 String 及 Integer, 不可以是原生型态
o 至于 new HashMap(...) 后面当然是 >(), 这是考集合泛型的建构方式
o 而 ma.put() 方法就是接收传递来的参数变量. 这边也决定了 HashMap 宣告
两个泛型(String 及 Integer)的前后顺序性.
o 最后, getName() 应该传回泛型字符串, 可选的 Code 只有 Set<String> 符合.
(6)
Place a result onto each call to indicate what would happen if the method call were inserted at line
9.
Note: Results can be used more than once.
Given the following Java code:
01.import java.util.*;
02.class A { }
03.class B extends A { }
04.public class Test {
05.public static void main(String[ ] args) {
06.List<A> listA = new LinkedList<A>();
07.List<B> listB = new LinkedList<B>();
08.List<Object> listO = new LinkedList<Object>();
09.// insert code here
10.}
11.public static void m1(List<? extends A> list) { }
12.public static void m2(List<A> list) { }
13.}
Method Calls: