0
0
Javaprogramming~10 mins

Variable declaration and initialization in Java - Interactive Code Practice

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

Complete the code to declare an integer variable named age.

Java
int [1];
Drag options to blanks, or click blank then click option'
Aage
Bnumber
Ccount
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name different from the one requested.
Forgetting the semicolon at the end (not tested here).
2fill in blank
medium

Complete the code to initialize the integer variable score with the value 100.

Java
int score = [1];
Drag options to blanks, or click blank then click option'
A10
B1
C100
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different number than 100.
Forgetting the semicolon at the end.
3fill in blank
hard

Fix the error in the code by completing the variable declaration for a double named price.

Java
double [1] = 9.99;
Drag options to blanks, or click blank then click option'
Aprice
Bcost
Camount
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than price.
Misspelling the variable name.
4fill in blank
hard

Fill both blanks to declare and initialize a boolean variable named isActive with the value true.

Java
[1] [2] = true;
Drag options to blanks, or click blank then click option'
Aboolean
Bint
CisActive
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong type like int.
Using a different variable name.
5fill in blank
hard

Fill all three blanks to declare and initialize a String variable named name with the value "Alice".

Java
[1] [2] = [3];
Drag options to blanks, or click blank then click option'
AString
Bname
C"Alice"
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong type like int.
Forgetting the quotes around the string value.
Using a different variable name.