Bird
Raised Fist0
Fluttermobile~20 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. Which data type in Flutter is used to store true or false values?
easy
A. bool
B. int
C. String
D. double

Solution

  1. Step 1: Understand the bool data type

    The bool data type stores only two values: true or false.
  2. Step 2: Compare with other data types

    int stores whole numbers, double stores decimals, and String stores text, so they do not fit true/false values.
  3. Final Answer:

    bool -> Option A
  4. Quick Check:

    bool = true or false [OK]
Hint: Remember: bool means true or false only [OK]
Common Mistakes:
  • Confusing bool with int
  • Thinking String can store true/false
  • Using double for true/false
2. Which of the following is the correct way to declare a double variable named price with value 9.99 in Flutter?
easy
A. double price = 9,99;
B. double price = 9.99;
C. int price = 9.99;
D. String price = 9.99;

Solution

  1. Step 1: Check the syntax for double declaration

    In Flutter, double values use a dot (.) as decimal separator, so 9.99 is correct.
  2. Step 2: Verify variable type and value match

    double price = 9.99; is correct. double price = 9,99; uses comma which is invalid. int price = 9.99; uses int for decimal value. String price = 9.99; uses String but value is numeric.
  3. Final Answer:

    double price = 9.99; -> Option B
  4. Quick Check:

    double uses dot for decimals [OK]
Hint: Use dot (.) for decimals in double, not comma [OK]
Common Mistakes:
  • Using comma instead of dot
  • Assigning decimal to int
  • Assigning number to String without quotes
3. What will be the output of this Flutter code?
int a = 5;
double b = 2.0;
print(a + b);
medium
A. 7.0
B. 7.00
C. 7
D. Error

Solution

  1. Step 1: Understand type promotion in addition

    Adding int and double results in a double value in Flutter.
  2. Step 2: Calculate the sum

    5 + 2.0 = 7.0 as a double, so print outputs 7.0.
  3. Final Answer:

    7.0 -> Option A
  4. Quick Check:

    int + double = double [OK]
Hint: int + double results in double output [OK]
Common Mistakes:
  • Expecting int output
  • Thinking print shows 7.00
  • Assuming syntax error
4. Identify the error in this Flutter code snippet:
bool isActive = "true";
medium
A. Variable name is invalid
B. Missing semicolon
C. bool cannot store text in quotes
D. No error, code is correct

Solution

  1. Step 1: Check bool assignment rules

    bool variables must be assigned true or false without quotes.
  2. Step 2: Analyze the code

    "true" is a String, not a bool, so this causes a type error.
  3. Final Answer:

    bool cannot store text in quotes -> Option C
  4. Quick Check:

    bool = true or false without quotes [OK]
Hint: Assign bool without quotes, quotes mean String [OK]
Common Mistakes:
  • Using quotes around true/false
  • Ignoring type mismatch errors
  • Assuming variable name causes error
5. You want to store a user's age, height in meters, name, and whether they are a student. Which Flutter data types should you use for age, height, name, and isStudent respectively?
hard
A. bool, String, double, int
B. double, int, bool, String
C. String, double, int, bool
D. int, double, String, bool

Solution

  1. Step 1: Match each variable to its data type

    Age is a whole number -> int; height is decimal -> double; name is text -> String; isStudent is true/false -> bool.
  2. Step 2: Verify option matches all types correctly

    int, double, String, bool matches int, double, String, bool in order for age, height, name, isStudent.
  3. Final Answer:

    int, double, String, bool -> Option D
  4. Quick Check:

    Whole number, decimal, text, true/false [OK]
Hint: Match data type to real-world meaning: number, decimal, text, true/false [OK]
Common Mistakes:
  • Mixing int and double
  • Using bool for text
  • Confusing order of types
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard