Blazor MCQ questions
Take a short practice test with instant feedback, then revise every question with its answer and the reason behind it.
- Questions
- 53
- From lessons
- 33
- Your last test
- —
Practice test
How does a child notify its parent?
All questions with answers
Which file extension do Blazor components use?
Show answer
Answer: B. .razor
.cshtml is for MVC views and Razor Pages.
Which directive makes a component routable?
Show answer
Answer: B. @page
@page "/counter" maps the URL to the component.
Which attribute marks a component parameter?
Show answer
Answer: B. [Parameter]
Parameters must be public properties.
Which syntax handles a button click?
Show answer
Answer: B. @onclick="Save"
Blazor event attributes start with @.
Which render mode runs .NET in the browser?
Show answer
Answer: C. InteractiveWebAssembly
The runtime is downloaded and executed via WebAssembly.
What transport does Interactive Server use?
Show answer
Answer: B. A SignalR connection (WebSockets when available)
UI events and DOM diffs travel over the circuit.
Which directive sets the render mode on a component?
Show answer
Answer: B. @rendermode
For example @rendermode InteractiveServer.
Which component renders a form with validation support?
Show answer
Answer: B. <EditForm>
EditForm creates an EditContext for the model.
Which component enables Data Annotations validation inside EditForm?
Show answer
Answer: B. <DataAnnotationsValidator />
ValidationSummary and ValidationMessage then display the errors.
Which method should a component call to re-render after an external event?
Show answer
Answer: B. StateHasChanged()
Use InvokeAsync(StateHasChanged) when called from another thread.
Which lifecycle method runs once when the component is first initialised?
Show answer
Answer: B. OnInitializedAsync
It may run twice when prerendering is enabled.
How does a child notify its parent?
Show answer
Answer: B. An EventCallback parameter
The parent passes a handler and the child calls InvokeAsync.
Which component shares a value with all descendants?
Show answer
Answer: A. <CascadingValue>
Descendants receive it with [CascadingParameter].
Which interface calls JavaScript from C#?
Show answer
Answer: A. IJSRuntime
await JS.InvokeVoidAsync("alert", "Hi").
When is JS interop safe in an Interactive Server component?
Show answer
Answer: C. In OnAfterRenderAsync
During prerendering there is no browser connection yet.
Which component shows UI only to authenticated users?
Show answer
Answer: B. <AuthorizeView>
It renders Authorized or NotAuthorized content.
Why does this list flicker and lose input focus on update?
Razor / Markup Illustrative @foreach (var item in Items) { <TodoRow Item="item" /> }Show answer
Answer: B. Items have no @key, so Blazor cannot match elements to data
Add @key="item.Id" so elements are preserved.
Which service creates short-lived DbContexts for components?
Show answer
Answer: B. IDbContextFactory<T>
Create one per operation with CreateDbContextAsync.
Which component catches rendering exceptions in part of the UI?
Show answer
Answer: A. <ErrorBoundary>
It shows ErrorContent instead of crashing the whole app.
Which component virtualises long lists?
Show answer
Answer: A. <Virtualize>
Only visible rows are rendered.
Which render mode keeps a SignalR connection open?
Show answer
Answer: B. Interactive Server
Interactive Server handles UI events on the server over a SignalR connection.
From the lesson: Blazor Web AppInteractive Auto uses WebAssembly for the very first visit.
Show answer
Answer: B. False
Auto uses Interactive Server first, then WebAssembly once the runtime has been downloaded and cached.
From the lesson: Blazor Web AppWhat file extension do Blazor components use?
Show answer
In a Blazor Web App, every page is interactive by default.
Show answer
Answer: B. False
Pages use static server rendering unless an interactive render mode is applied.
From the lesson: Introduction to BlazorOver what does Interactive Server send UI updates?
Show answer
Answer: B. A SignalR connection (circuit)
Interactive Server keeps a SignalR circuit per user.
From the lesson: Blazor Architecture