DartInterview 2 min read

Dart interview questions for beginners: values, functions and null safety

Explain foundational Dart behavior with a short code example and a practical limitation.

On this page

Use these questions after building the basic examples. A strong answer gives a definition, predicts behavior and connects the rule to a real design decision. Do not memorize one sentence without being able to run a small counterexample.

What is the difference between var, final and const?

var asks for inferred static typing and permits reassignment. final permits a single assignment. const requires a compile-time constant expression in its supported context. A final list can still have its contents mutated; distinguish variable binding from object mutability.

When should you use a named parameter?

Use it when a call benefits from labeling optional or easily confused inputs. required expresses a mandatory named argument. Give a cart calculation two integer arguments and explain how named inputs can prevent an accidental swap.

What does sound null safety change?

A non-nullable type excludes null at typed boundaries. A nullable value needs a deliberate check, fallback or result path before non-nullable use. The non-null assertion is a runtime promise, not validation. Explain the difference between “not provided,” “empty” and a valid zero.

List, Set or Map?

A List preserves an ordered sequence, a Set models unique membership, and a Map associates keys with values. For a stock report, use a list of scans, a set of unique SKUs and a map of per-SKU counts. Explain what information each loses or preserves.

A short prediction exercise

void main() {
  final original = [1, 2];
  final alias = original;
  alias.add(3);
  print(original.length);
}

The output is 3 because both variables reference the same mutable list. Explain how a copy and an unmodifiable list change different parts of this behavior.

Practice

Answer each question aloud, then write a small program verifying your claim. Use the basic path for the worked explanations. Include one mistake a learner might make and how the analyzer or a test would reveal it.

How this topic connects

Apply it next

Lesson progressMark complete after checking the example and exercise.

Find your next idea

Search lessons, code examples and projects.

Type a few words to start exploring.