Control flow statements are essential for programming logic. This set of 30 MCQs covers if-else, switch-case, loops (for, while, do-while), and break/continue statements in Dart.
if statement in Dart?if condition {}if (condition) {}if condition:if [condition] {}if-else statement in Dart?else block is mandatory.if block must have curly braces.if statements are not allowed.int x = 10; if (x > 5) print("Greater"); else print("Smaller"); if statement?if condition then action;if condition: action;if (condition) action;if {condition} action;if statement evaluates to false?if statement?&& or || operators.== only.if blocks.switch-case.int x = 8; if (x < 5) print("Less"); else if (x == 8) print("Equal"); else print("Greater"); if-else statement in Dart?if (true) { print("Yes"); }if (false) { print("No"); } else { print("Yes"); }if (true) { print("True"); } else if (false) { print("False"); }if (true) print("True") else print("False");case block in Dart?break statement is missing in a Dart switch-case block?switch-case syntax in Dart?switch x { case 1: ... }switch (x) { case 1: ... }switch [x] { case 1: ... }switch<x> { case 1: ... }default case in a switch statement?switch statement execute the same code?break.switch statements?var grade = 'A'; switch (grade) { case 'A': print("Excellent"); break; case 'B': print("Good"); break; default: print("Needs Improvement"); } for loop in Dart begin?for (var i = 0; i < n; i++)for i in range(n)for i = 0 until nloop for (i in n)while loop syntax in Dart?while condition { ... }while (condition) { ... }while [condition] { ... }while condition do { ... }while and do-while loops?do-while executes at least once.while executes at least once.while is faster.for loop in Dart?for (var item in list)for each (item in list)foreach (var item in list)loop (list as item)for (int i = 0; i < 3; i++) { print(i); } int x = 10; do { print(x); x--; } while (x > 0); for loop contain another for loop in Dart?while loops.while loop do?int i = 0; while (i < 5) { print(i); i++; } int i = 5; while (i > 0) { i--; if (i == 2) break; print(i); } a) 4 3 2break statement do in Dart loops?continue statement do in Dart?break statement be used?for loop when a condition is met?break.continue.exit.terminate.while (true) { }for ( ; ; ) { }do { } while (true)Here are the answers for the 30 MCQs based on Control Flow Statements in Dart:
| Qno | Answer |
|---|---|
| 1 | b) if (condition) {} |
| 2 | c) It allows conditional branching. |
| 3 | a) Greater |
| 4 | c) if (condition) action; |
| 5 | c) The program skips the block. |
| 6 | a) Use && or ` |
| 7 | b) Equal |
| 8 | d) if (true) print("True") else print("False"); |
| 9 | a) break |
| 10 | b) It executes the next case(s). |
| 11 | b) switch (x) { case 1: ... } |
| 12 | a) Executes if no case matches. |
| 13 | c) Yes, by chaining them together. |
| 14 | d) All data types |
| 15 | a) Excellent |
| 16 | a) for (var i = 0; i < n; i++) |
| 17 | b) while (condition) { ... } |
| 18 | a) do-while executes at least once. |
| 19 | a) for (var item in list) |
| 20 | a) 0 1 2 |
| 21 | a) Prints numbers 10 to 1 |
| 22 | a) Yes, it is called nesting. |
| 23 | a) Print 0 to 4 |
| 24 | b) break |
| 25 | b) 4 3 |
| 26 | a) Exits the loop immediately. |
| 27 | b) Skips the current iteration. |
| 28 | c) Both loops and switch statements |
| 29 | a) Use break. |
| 30 | d) All of the above |