Java Reference
In-Depth Information
C.
hellohiola
D.
hihello
E.
The code does not compile.
7.
Which of the following statements are valid? (Choose three.)
A.
List<String> list = new Vector<String>();
B.
HashSet<Number> hs = new HashSet<Integer>();
C.
Map<String, ? extends Number> hm = new HashMap<String, Integer>();
D.
HashSet<? super ClassCastException> set = new HashSet<Exception>();
E.
List<Object> values = new LinkedHashSet<Object> ();
8.
What is the result of the following program?
1. public class Hello<T> {
2. T t;
3.
4. public Hello(T t) {
5. this.t = t;
6. }
7.
8. public String toString() {
9. return t.toString();
10. }
11.
12. public static void main(String [] args) {
13. System.out.print(new Hello<String>(“hi”));
14. System.out.print(new Hello(“there”));
15. }
16. }
A.
hi
B.
hi followed by a runtime exception
C.
hithere
D.
Compiler error on line 9
E.
Compiler error on line 14
9.
Given the following statements:
6. Set<Number> numbers = new HashSet<Number>();
7. numbers.add(new Integer(86));
8. numbers.add(75);
9. numbers.add(new Integer(86));
10. numbers.add(null);
Search WWH ::
Custom Search