Change Detection Questions with Answers

13 practice questions on Change Detection (Angular) with answers and step-by-step solutions. Try 10 samples below, then practise all 13 free in the AptiNest app.

Sample questions

Question 1Easy

What triggers Angular's default change detection in typical apps?

  1. Only full page reloads, since the framework ignores everything else
  2. Only route changes performed through the router service
  3. Only manual calls to a global render() function by the developer
  4. Asynchronous events such as clicks, timers and HTTP responses

Answer: D. Asynchronous events such as clicks, timers and HTTP responses

Explanation

Zone.js notifies Angular when async tasks finish, prompting a change detection run.

Step-by-step solution

  1. Angular uses Zone.js to track asynchronous events like clicks and HTTP requests.
  2. When these events complete, Zone.js triggers Angular's change detection.
  3. This ensures the view updates automatically without manual intervention.
  4. Change detection runs in response to any async event, not just route changes or full reloads.
  5. Thus, asynchronous events trigger Angular's default change detection.
  6. The correct answer is Asynchronous events such as clicks, timers and HTTP responses.

Why the other options are wrong

  • A. Angular does not rely only on full page reloads; it checks after events inside the app.
  • B. Route changes are one trigger, but not the only one; clicks and timers also run change detection.
  • C. Calling render() is not how Angular updates views; change detection runs automatically via Zone.js.

Tip: Remember: Angular detects changes automatically for async events, not just route changes or full reloads.

Question 2Easy

Which decorator-free approach lets a service share state with components?

  1. Global window variables shared by all code
  2. Querying the DOM directly from each component
  3. Inject a shared service holding data or signals
  4. Direct access to the parent component instance

Answer: C. Inject a shared service holding data or signals

Explanation

DI singleton state is standard.

Step-by-step solution

  1. Use services.

Why the other options are wrong

  • A. Global window variables are not how Angular shares state.
  • B. Querying the DOM directly bypasses Angular and shares no state.
  • D. Reaching into the parent instance couples components; use a service.

Question 3Easy

What does Angular change detection do?

  1. Compiles TypeScript
  2. Downloads lazy modules from the server
  3. Validates the route configuration at startup
  4. Checks component data and updates the DOM when values change

Answer: D. Checks component data and updates the DOM when values change

Explanation

It keeps the view in sync with the model.

Step-by-step solution

  1. Model -> view.

Why the other options are wrong

  • A. Compiling TypeScript happens at build time, not in change detection.
  • B. Downloading lazy modules is the router's job, not change detection.
  • C. Route validation happens at routing setup, not during change detection.

Question 4Medium

What is Zone.js responsible for in classic Angular?

  1. Patching async APIs so Angular knows when to run change detection
  2. Compiling templates
  3. Routing between lazy-loaded modules
  4. Caching HTTP responses between pages

Answer: A. Patching async APIs so Angular knows when to run change detection

Explanation

After async tasks complete, Angular checks the view.

Step-by-step solution

  1. Patches timers and events.

Why the other options are wrong

  • B. Zone.js does not compile templates; the compiler does that.
  • C. Zone.js does not route between lazy-loaded modules.
  • D. Zone.js does not cache HTTP responses between pages.

Question 5Medium

With OnPush, a parent mutates an object input in place (obj.name = 'x'). What happens?

  1. The child always updates because Angular compares objects by value
  2. An error is thrown on the mutation
  3. The child may not update because the reference is unchanged
  4. The parent is destroyed and recreated

Answer: C. The child may not update because the reference is unchanged

Explanation

OnPush compares references.

Step-by-step solution

  1. Same reference.

Why the other options are wrong

  • A. Angular compares object inputs by reference, not by value.
  • B. Mutating an object input throws no error; the child may just not update.
  • D. Mutating a property never destroys or recreates the parent.

Tip: Use immutable updates.

Question 6Medium

What does ChangeDetectionStrategy.OnPush do?

  1. Disables change detection entirely for the component, so it never updates its view after the first render
  2. Checks the component only when inputs change by reference, events fire or it is marked
  3. Runs detection every millisecond using a timer
  4. Detects only changes caused by HTTP calls

Answer: B. Checks the component only when inputs change by reference, events fire or it is marked

Explanation

It reduces checks.

Step-by-step solution

  1. Reference changes.

Why the other options are wrong

  • A. OnPush still checks the component when inputs or events change.
  • C. OnPush does not poll on a timer; it checks on specific triggers.
  • D. OnPush reacts to inputs, events and marking, not only HTTP calls.

Question 7Medium

What is the role of ChangeDetectorRef.markForCheck()?

  1. Marks the whole app as dirty and re-renders every component synchronously
  2. Destroys the component view and recreates it on the next change cycle
  3. Marks the component and its ancestors for checking in the next pass
  4. Disables change detection for this component permanently, for good

Answer: C. Marks the component and its ancestors for checking in the next pass

Explanation

markForCheck schedules the OnPush path to be checked at the next cycle.

Step-by-step solution

  1. ChangeDetectorRef.markForCheck tells Angular to check this component in the next change detection pass.
  2. It marks the component and all its parent components for checking during the next cycle.
  3. This ensures any changes are reflected in the view without full re-rendering.
  4. The method does not destroy or permanently disable the component's change detection.
  5. Only the marked components are checked, improving performance.

Why the other options are wrong

  • A. markForCheck does not re-render the whole app synchronously; it only marks the component and its ancestors.
  • B. markForCheck does not destroy or recreate the view; it only schedules a check.
  • D. markForCheck does not disable change detection; it asks for a check on the next pass.

Tip: Use markForCheck to selectively trigger change detection in Angular without affecting other components.

Question 8Medium

What does ChangeDetectionStrategy.OnPush mean for a component?

  1. Checked only when inputs change by reference, an event fires inside, or it is marked dirty
  2. It never updates, because the view is frozen after creation
  3. It is checked only once at startup, then ignored for the app lifetime
  4. It is checked only on keystrokes inside input elements and nowhere else

Answer: A. Checked only when inputs change by reference, an event fires inside, or it is marked dirty

Explanation

OnPush limits checks to specific triggers, improving performance when data is treated as immutable.

Step-by-step solution

  1. ChangeDetectionStrategy.OnPush tells Angular to check for changes only under certain conditions.
  2. These conditions include input changes by reference, events inside the component, or when marked dirty.
  3. This reduces unnecessary checks and improves performance with immutable data.
  4. It does not freeze the view or ignore updates entirely, so option B is correct.
  5. The strategy ensures checks happen only when needed, not on keystrokes alone.
  6. Final answer: Checked only when inputs change by reference, an event fires inside, or it is marked dirty.

Why the other options are wrong

  • B. OnPush still updates when triggered; the view is not frozen after creation.
  • C. OnPush does not stop checking after startup; it checks again when its inputs or events change.
  • D. OnPush is not limited to keystrokes; it checks on input reference change, inside events, or markForCheck.

Tip: Use OnPush for immutable data to boost app performance without freezing views.

Question 9Hard

What does ExpressionChangedAfterItHasBeenCheckedError (dev mode) signal?

  1. An HTTP request failed and the observable emitted an error before subscribe
  2. A route could not be found and the router fell back to the wildcard
  3. A template file is missing from the production bundle at render time
  4. A binding changed between the check and the verification pass

Answer: D. A binding changed between the check and the verification pass

Explanation

In development Angular re-checks bindings and throws if a value changed after being checked, often from updating state in a lifecycle hook.

Step-by-step solution

  1. ExpressionChangedAfterItHasBeenCheckedError occurs when a binding changes after Angular has checked it.
  2. This error happens in dev mode during change detection cycles.
  3. Angular re-checks bindings to catch unexpected changes post-check.
  4. Such changes often happen if state is updated in lifecycle hooks after check.
  5. The error signals that a binding changed between the check and verification pass.
  6. Final answer: A binding changed between the check and the verification pass.

Why the other options are wrong

  • A. An HTTP error before subscribe is not this error; that is a request failure, not a binding mismatch.
  • B. A missing route is a router error such as NavigationError, not this binding error.
  • C. A missing template is a build or load problem, not a binding that changed during the dev-mode check.

Tip: Fix by ensuring state updates happen before Angular checks bindings, like in ngOnInit or using OnChanges.

Question 10Hard

ExpressionChangedAfterItHasBeenCheckedError occurs when:

  1. A route is missing from the route configuration, so navigation fails with a 404 page
  2. A binding value changes during the change detection pass after being checked
  3. An HTTP request fails with a server error
  4. A pipe is declared as impure

Answer: B. A binding value changes during the change detection pass after being checked

Explanation

Dev mode double-checks values.

Step-by-step solution

  1. Value changed mid-check.

Why the other options are wrong

  • A. A missing route is a navigation error, not this change detection error.
  • C. A failing HTTP request does not cause this change detection error.
  • D. An impure pipe does not cause this error.

Practise all 13 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Angular topics · All topics