0
0
Javaprogramming~15 mins

Primitive vs reference storage in Java - Interactive Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a primitive integer variable.

Java
int number = [1];
🎯 Drag options to blanks, or click blank then click option
A10
B"10"
Cnew Integer(10)
DInteger.valueOf(10)
Attempts:
3 left
2fill in blank
medium

Complete the code to create a reference to a String object.

Java
String text = [1];
🎯 Drag options to blanks, or click blank then click option
A10
Bnew int(5)
C"Hello"
Dtrue
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to assign a new Integer object to a variable.

Java
Integer value = [1];
🎯 Drag options to blanks, or click blank then click option
Anew Integer(10)
B"10"
C10
DInteger.parseInt("10")
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create an array of primitive ints and assign a value.

Java
int[] numbers = new int[[1]];
numbers[[2]] = 5;
🎯 Drag options to blanks, or click blank then click option
A3
B0
C1
D5
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a String array, assign a value, and print it.

Java
String[] words = new String[[1]];
words[[2]] = [3];
System.out.println(words[0]);
🎯 Drag options to blanks, or click blank then click option
A2
B0
C"hello"
D"world"
Attempts:
3 left