Oracle
1Z0-805 · Question #36
Which code fragments print 1?
The correct answer is A. String arr [] = {"1", "2", "3"}; C. String arr [] = {"1", "2", "3"}. Note:You can replace the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>) as long as the compiler can infer the type arguments from the context. This pair of angle brackets is informally called the diamond.
Generics and Collections
Question
Which code fragments print 1?
Options
- AString arr [] = {"1", "2", "3"};
- BString arr [] = {"1", "2", "3"};
- CString arr [] = {"1", "2", "3"};
- DString arr [] = {"1","2","3"};
- EString arr [] = {"1","2","3"};
How the community answered
(58 responses)- A84% (49)
- B9% (5)
- D5% (3)
- E2% (1)
Explanation
Note:You can replace the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>) as long as the compiler can infer the type arguments from the context. This pair of angle brackets is informally called the diamond.
Topics
#TreeSet#iterator#Set deduplication#collections
Community Discussion
No community discussion yet for this question.