Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an object stored in heap memory.
Java
String str = new [1]("Hello");
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to assign a new object reference to the variable.
Java
MyClass obj = [1] MyClass();🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code to properly create an array in heap memory.
Java
int[] numbers = new int[1]5;
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create a new object and call its method.
Java
MyObject obj = [1] MyObject(); obj.[2]();
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a HashMap, add a key-value pair, and retrieve a value.
Java
HashMap<String, Integer> map = [1] HashMap<>(); map.[2]("age", 30); int age = map.[3]("age");
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
