0
0
Fluttermobile~20 mins

Data types (int, double, String, bool) in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Data Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What will this Flutter Text widget display?
Consider this Flutter code snippet:
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')
ATotal: 17.5 - Active: false
BTotal: 17.5 - Active: true
CTotal: $17.5 - Active: true
DTotal: $17.5 - Active: false
Attempts:
2 left
💡 Hint
Remember that \$ inside a string escapes the dollar sign to show it literally.
📝 Syntax
intermediate
1: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?
Adouble price = 9.99;
Bint price = 9.99;
CString price = 9.99;
Dbool price = 9.99;
Attempts:
2 left
💡 Hint
Decimals need a type that supports fractional numbers.
🧠 Conceptual
advanced
1:30remaining
What is the result of this Dart expression?
Given:
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);
A3.0
Btrue
CTypeError
Dfalse
Attempts:
2 left
💡 Hint
Compare 3 and 2.0 using > operator.
🔧 Debug
advanced
2:00remaining
Why does this Dart code cause an error?
Look at this code:
int x = 5;
String y = x + 3;

Why does it cause an error?
Flutter
int x = 5;
String y = x + 3;
AYou cannot assign int to String without conversion.
BVariables must be declared with var keyword.
CYou cannot add int to int and assign to String directly.
DThe + operator is not defined for int types.
Attempts:
2 left
💡 Hint
Check the types on both sides of the assignment.
lifecycle
expert
2:00remaining
What happens if you try to change a final int variable in Flutter?
Consider this code:
final int count = 10;
count = 15;

What will happen when you run this code?
Flutter
final int count = 10;
count = 15;
AThe value of count changes to 15 at runtime.
BNo error, count becomes 15.
CRuntime error: Variable 'count' is immutable.
DCompile-time error: Cannot assign to final variable 'count'.
Attempts:
2 left
💡 Hint
final variables cannot be reassigned after initialization.