Java Reference
In-Depth Information
21. What is the result of the following statements?
10. List<String> one = new ArrayList<String>();
11. one.add(“abc”);
12. List<String> two = new ArrayList<String>();
13. two.add(“abc”);
14. if(one == two) {
15. System.out.println(“A”);
16. } else if(one.equals(two)) {
17. System.out.println(“B”);
18. } else {
19. System.out.println(“C”);
20. }
A. A
B. B
C. C
D. Compiler error on line 14
E. Compiler error on line 16
22. What is the result of the following code?
10. List<String> one = new ArrayList<String>();
11. one.add(“abc”);
12. List<String> two = new Vector<String>();
13. two.add(“abc”);
14. if(one == two) {
15. System.out.println(“A”);
16. } else if(one.equals(two)) {
17. System.out.println(“B”);
18. } else {
19. System.out.println(“C”);
20. }
A. A
B. B
C. C
D. Compiler error on line 14
E. Compiler error on line 16
Search WWH ::




Custom Search