Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to autobox the int value into an Integer object.
Java
int num = 10; Integer boxedNum = [1];
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to unbox the Integer object to a primitive int.
Java
Integer boxedNum = 20; int num = [1];
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in autoboxing when adding a primitive int to a List of Integer.
Java
List<Integer> list = new ArrayList<>(); int num = 5; list.add([1]);
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create a Map with Integer keys and values using autoboxing.
Java
Map<Integer, Integer> map = new HashMap<>(); int key = 1; int value = 100; map.put([1], [2]);
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a List of Integer squares using autoboxing and a for loop.
Java
List<Integer> squares = new ArrayList<>(); for (int i = 1; i <= 5; i++) { squares.add(i [1] [2]); } int firstSquare = squares.get([3]);
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
