Dart is a programming language designed by Google. It is used to build mobile, desktop, server, and web apps. Flutter uses Dart to create fast and beautiful apps.
Click to reveal answer
beginner
What type of language is Dart?
Dart is an object-oriented, class-based language with C-style syntax. It supports both just-in-time (JIT) and ahead-of-time (AOT) compilation.
Click to reveal answer
intermediate
How does Dart handle null safety?
Dart has sound null safety, which means variables can’t be null unless you say they can. This helps avoid many common bugs related to null values.
Click to reveal answer
intermediate
What is a 'Future' in Dart?
A Future represents a value that will be available later, like the result of a network call. It helps write asynchronous code that doesn’t block the app.
Click to reveal answer
beginner
Why is Dart good for mobile app development?
Dart compiles to native code for fast performance. It also supports hot reload, which lets developers see changes instantly without restarting the app.
Click to reveal answer
Which company created Dart?
AMicrosoft
BApple
CGoogle
DFacebook
✗ Incorrect
Google designed Dart to build apps across multiple platforms.
What kind of syntax does Dart use?
AC-style
BPython-style
CHTML-style
DSQL-style
✗ Incorrect
Dart uses C-style syntax with braces and semicolons.
What feature helps Dart avoid null errors?
AGarbage collection
BNull safety
CType inference
DHot reload
✗ Incorrect
Null safety ensures variables can’t be null unless explicitly allowed.
What does a Future represent in Dart?
AA delayed value
BA synchronous value
CA UI widget
DA database connection
✗ Incorrect
A Future holds a value that will be available later, useful for async tasks.
What is a key benefit of Dart's hot reload?
AFaster app startup
BImproved battery life
CBetter memory management
DInstantly see code changes without restarting
✗ Incorrect
Hot reload lets developers see changes immediately, speeding up development.
Explain the main features of Dart that make it suitable for Flutter app development.
Think about language design and developer experience.
You got /5 concepts.
Describe how Dart handles asynchronous programming and why it is important for mobile apps.
Consider how apps stay responsive while waiting for data.
You got /5 concepts.
Practice
(1/5)
1. What is Dart primarily used for in Flutter development?
easy
A. Writing the app's code and logic
B. Designing the app's images
C. Creating database schemas
D. Managing app deployment
Solution
Step 1: Understand Dart's role
Dart is the programming language used to write Flutter apps.
Step 2: Identify what Dart does in Flutter
Dart handles the app's code and logic, not images or deployment.
Final Answer:
Writing the app's code and logic -> Option A
Quick Check:
Dart = app code language [OK]
Hint: Dart is the language, not design or deployment [OK]
Common Mistakes:
Confusing Dart with design tools
Thinking Dart manages deployment
Mixing Dart with database design
2. Which of the following is the correct way to declare a variable in Dart?
easy
A. string name = 'Flutter';
B. let name = 'Flutter';
C. var name = 'Flutter';
D. dim name = 'Flutter';
Solution
Step 1: Recall Dart variable syntax
Dart uses 'var' to declare variables with inferred types.
Step 2: Check each option
'let' is JavaScript, 'string' lowercase is invalid, 'dim' is VB syntax.
Final Answer:
var name = 'Flutter'; -> Option C
Quick Check:
Use 'var' for variables in Dart [OK]
Hint: Dart uses 'var' for variables, not 'let' or 'dim' [OK]
Common Mistakes:
Using JavaScript 'let'
Using lowercase 'string'
Using VB 'dim'
3. What will be the output of this Dart code?
void main() {
var list = [1, 2, 3];
print(list.map((x) => x * 2).toList());
}
medium
A. [1, 2, 3]
B. Error: map is not a function
C. [3, 6, 9]
D. [2, 4, 6]
Solution
Step 1: Understand the map function
map applies the function (x * 2) to each element in the list.
Step 2: Calculate the mapped list
1*2=2, 2*2=4, 3*2=6, so the new list is [2, 4, 6].
Final Answer:
[2, 4, 6] -> Option D
Quick Check:
map doubles each element = [2,4,6] [OK]
Hint: map applies function to each list item [OK]
Common Mistakes:
Confusing map with filter
Expecting original list
Thinking map causes error
4. Identify the error in this Dart code snippet:
void main() {
int number = '5';
print(number);
}
medium
A. Missing semicolon after print statement
B. Cannot assign a String to an int variable
C. Variable 'number' is not declared
D. print() function is undefined
Solution
Step 1: Check variable assignment types
Variable 'number' is declared as int but assigned a String '5'.
Step 2: Understand Dart type safety
Dart does not allow assigning a String to an int variable without conversion.
Final Answer:
Cannot assign a String to an int variable -> Option B
Quick Check:
Type mismatch error = Cannot assign a String to an int variable [OK]
Hint: Check variable types match assigned values [OK]
Common Mistakes:
Ignoring type mismatch
Thinking semicolon missing
Assuming print undefined
5. How can you create a Dart function that returns the sum of two numbers only if both are positive, otherwise returns zero?
hard
A. int sum(int a, int b) => (a > 0 && b > 0) ? a + b : 0;
B. int sum(int a, int b) { if (a > 0 || b > 0) return a + b; else return 0; }
C. int sum(int a, int b) => a + b;
D. int sum(int a, int b) { return a > 0 && b > 0 ? a - b : 0; }
Solution
Step 1: Understand the condition
Sum only if both a and b are positive (greater than 0).
Step 2: Check each option's logic
int sum(int a, int b) => (a > 0 && b > 0) ? a + b : 0; uses correct '&&' and returns sum or 0. Others use '||' (wrong condition), always sum, or subtract instead of add.
Final Answer:
int sum(int a, int b) => (a > 0 && b > 0) ? a + b : 0; -> Option A
Quick Check:
Use '&&' for both positive check [OK]
Hint: Use '&&' to check both positive before summing [OK]
Common Mistakes:
Using '||' instead of '&&'
Always summing without condition
Subtracting instead of adding
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.