Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an Integer wrapper object from a primitive int.
Java
Integer num = [1];🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to convert a String to an Integer using wrapper class methods.
Java
Integer num = Integer.[1]("123");
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code to correctly convert an Integer to a primitive int.
Java
int value = num.[1]();🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create a list of Integer objects from an array of ints.
Java
int[] arr = {1, 2, 3};
List<Integer> list = new ArrayList<>();
for (int num : arr) {
list.[1](Integer.[2](num));
}🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a map of String keys to Integer values where values are only added if greater than 10.
Java
Map<String, Integer> map = new HashMap<>(); for (String key : keys) { Integer val = Integer.[1](key.length()); if (val [2] 10) { map.[3](key, val); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
