Challenge - 5 Problems
Data Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this Flutter Text widget display?
Consider this Flutter code snippet:
What text will appear on the screen?
int count = 5;
double price = 3.5;
String label = 'Total';
bool isActive = true;
Text('$label: \$${count * price} - Active: $isActive')What text will appear on the screen?
Flutter
int count = 5; double price = 3.5; String label = 'Total'; bool isActive = true; Text('$label: \$${count * price} - Active: $isActive')
Attempts:
2 left
💡 Hint
Remember that \$ inside a string escapes the dollar sign to show it literally.
✗ Incorrect
The string uses \$ to show the dollar sign literally, then ${count * price} calculates 5 * 3.5 = 17.5. The bool isActive is true, so the full text is 'Total: $17.5 - Active: true'.
📝 Syntax
intermediate1:30remaining
Which option correctly declares a double variable in Dart?
You want to store a decimal number in a variable named price. Which declaration is correct?
Attempts:
2 left
💡 Hint
Decimals need a type that supports fractional numbers.
✗ Incorrect
double is the correct type for decimal numbers. int only stores whole numbers. String stores text. bool stores true/false.
🧠 Conceptual
advanced1:30remaining
What is the result of this Dart expression?
Given:
What is the value of c?
int a = 3; double b = 2.0; bool c = (a > b);
What is the value of c?
Flutter
int a = 3; double b = 2.0; bool c = (a > b);
Attempts:
2 left
💡 Hint
Compare 3 and 2.0 using > operator.
✗ Incorrect
3 is greater than 2.0, so (a > b) is true. The bool c stores true.
🔧 Debug
advanced2:00remaining
Why does this Dart code cause an error?
Look at this code:
Why does it cause an error?
int x = 5; String y = x + 3;
Why does it cause an error?
Flutter
int x = 5; String y = x + 3;
Attempts:
2 left
💡 Hint
Check the types on both sides of the assignment.
✗ Incorrect
x + 3 is an int (5 + 3 = 8). You cannot assign an int directly to a String variable without converting it to a string.
❓ lifecycle
expert2:00remaining
What happens if you try to change a final int variable in Flutter?
Consider this code:
What will happen when you run this code?
final int count = 10; count = 15;
What will happen when you run this code?
Flutter
final int count = 10; count = 15;
Attempts:
2 left
💡 Hint
final variables cannot be reassigned after initialization.
✗ Incorrect
final means the variable can only be set once. Trying to assign a new value causes a compile-time error.