-->
当前位置:首页 > 题库

单选题:Given code below:

Luz5年前 (2021-05-10)题库1062
Given code below:
```JAVA
Set s = new HashSet();
s.add(1);
s.add(2);
s.add(1);
```
Which statement below is correct? @[A](2)
A. It compiles, but only two element left in s
B. It does not compile because 1 and 2 are not objects of Integer
C. It compiles but exception raises at line 2, for 1 is not an objects of Integer
D. It compiles but exception raises at line 4, for 1 is already in the set




A.It compiles, but only two element left in s
B.It does not compile because 1 and 2 are not objects of Integer
C.It compiles but exception raises at line 2, for 1 is not an objects of Integer
D.It compiles but exception raises at line 4, for 1 is already in the set


答案:A