0
0
Javaprogramming~10 mins

Default values 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 with its default value.

Java
int number = [1];
Drag options to blanks, or click blank then click option'
A"0"
Bnull
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using null for int variables causes errors.
Using quotes around 0 makes it a string, not an int.
2fill in blank
medium

Complete the code to declare a boolean variable with its default value.

Java
boolean isActive = [1];
Drag options to blanks, or click blank then click option'
Anull
Bfalse
Ctrue
D"false"
Attempts:
3 left
💡 Hint
Common Mistakes
Using null for boolean causes errors.
Using quotes makes it a string, not a boolean.
3fill in blank
hard

Fix the error in the code by completing the declaration of a String variable with its default value.

Java
String name = [1];
Drag options to blanks, or click blank then click option'
Anull
B0
C""
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using empty quotes instead of null for default String value.
Assigning 0 or false to a String causes errors.
4fill in blank
hard

Fill both blanks to declare a double and a char variable with their default values.

Java
double price = [1];
char grade = [2];
Drag options to blanks, or click blank then click option'
A0.0
B'\u0000'
C0
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 for char instead of '\u0000'.
Using null for primitive types causes errors.
5fill in blank
hard

Fill all three blanks to declare variables of types long, float, and boolean with their default values.

Java
long count = [1];
float rate = [2];
boolean flag = [3];
Drag options to blanks, or click blank then click option'
A0
B0.0f
Cfalse
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using null for primitives causes errors.
Forgetting the 'f' suffix for float literals.