Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer variable named 'age' with value 25.
Java
int [1] = 25;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the value instead of the variable name.
Using a keyword instead of a name.
✗ Incorrect
The variable name 'age' is used to store the value 25.
2fill in blank
mediumComplete the code to print the value of the variable 'score'.
Java
System.out.println([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the variable name.
Using method names instead of variable.
✗ Incorrect
To print the value stored in the variable, use its name without quotes.
3fill in blank
hardFix the error in the code by completing the variable declaration correctly.
Java
double [1] = 9.99;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the value as the variable name.
Repeating the type keyword.
✗ Incorrect
The variable name 'price' is needed to store the value 9.99.
4fill in blank
hardFill both blanks to declare a String variable 'name' and assign it the value "Alice".
Java
String [1] = [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for the text.
Using wrong variable names.
✗ Incorrect
The variable 'name' stores the text "Alice" as a String.
5fill in blank
hardFill all three blanks to declare an integer variable 'count', assign 10, and print it.
Java
int [1] = [2]; System.out.println([3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names in declaration and print.
Not assigning a value.
✗ Incorrect
Declare 'count' as int with 10, then print 'count' to show the value.