0
0
Javaprogramming~10 mins

Primitive data types 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 a variable of type int.

Java
int number = [1];
Drag options to blanks, or click blank then click option'
Atrue
B"10"
C10.5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers, which makes them strings.
Assigning decimal numbers to int variables.
2fill in blank
medium

Complete the code to declare a variable of type boolean.

Java
boolean isJavaFun = [1];
Drag options to blanks, or click blank then click option'
A"true"
B1
Ctrue
Dyes
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around true or false, making them strings.
Using numbers like 1 or 0 instead of boolean literals.
3fill in blank
hard

Fix the error in the code to correctly declare a double variable.

Java
double price = [1];
Drag options to blanks, or click blank then click option'
A15.0
B15,0
C15
D"15.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas instead of dots for decimals.
Putting the number inside quotes, making it a string.
4fill in blank
hard

Fill both blanks to declare a char variable and assign a letter.

Java
char letter = [1][2];
Drag options to blanks, or click blank then click option'
A"A"
B'A'
C'B'
D"B"
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes instead of single quotes for chars.
Leaving the character unquoted.
5fill in blank
hard

Fill all three blanks to declare variables of types int, float, and boolean.

Java
int count = [1];
float temperature = [2]f;
boolean isActive = [3];
Drag options to blanks, or click blank then click option'
A100
B36.6
Ctrue
D"true"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around boolean values.
Omitting the 'f' suffix for float literals.
Assigning decimal numbers to int variables.