Problem statement: We need to find out the correct pieces of java code.
- ArrayList<Integer> l = new ArrayList<>();
- ArrayList<Integer> l = new ArrayList<Integer>();
- ArrayList<int> l = new ArrayList<int>();
- ArrayList<int> l = new ArrayList<>();
- LinkedList<Integer> l = new LinkedList<Integer>();
- LinkedList<Integer> l = new LinkedList<>();
- LinkedList<int> l = new LinkedList<>();
- Map<String, Integer> m = new HashMap<String, Integer>();
- Map<String, Integer> m = new HashMap<>();
- Map<String, int> m = new HashMap<>();
Answer:
- Correct- we can keep right angular braces empty
- Correct- we can specify the right angular braces data type also
- Incorrect-generic support only wrapper class for auto boxing to Object type
- Incorrect-generic support only wrapper class for auto boxing to Object type
- Correct- we can specify the right angular braces data type also
- Correct- we can keep right angular braces empty
- Incorrect- generic doen't support primitive data type
- Correct - we can specify the right angular braces data type also
- Correct - we can keep right angular braces empty
- Incorrect- generic doen't support primitive data type
No comments:
Post a Comment