Multiple choice practice

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

Blazor practice testMultiple choice Question 1 of 10

How does a child notify its parent?

Score so far: 0/0

All questions with answers

  1. Which file extension do Blazor components use?

    • A.cshtml
    • B.razor
    • C.blazor
    • D.cs only
    Show answer

    Answer: B. .razor

    .cshtml is for MVC views and Razor Pages.

  2. Which directive makes a component routable?

    • A@route
    • B@page
    • C@url
    • D@path
    Show answer

    Answer: B. @page

    @page "/counter" maps the URL to the component.

  3. Which attribute marks a component parameter?

    • A[Input]
    • B[Parameter]
    • C[Prop]
    • D[Bind]
    Show answer

    Answer: B. [Parameter]

    Parameters must be public properties.

  4. Which syntax handles a button click?

    • Aonclick="Save()"
    • B@onclick="Save"
    • C(click)="Save()"
    • Dv-on:click="Save"
    Show answer

    Answer: B. @onclick="Save"

    Blazor event attributes start with @.

  5. Which render mode runs .NET in the browser?

    • AStatic SSR
    • BInteractiveServer
    • CInteractiveWebAssembly
    • DPrerendered
    Show answer

    Answer: C. InteractiveWebAssembly

    The runtime is downloaded and executed via WebAssembly.

  6. What transport does Interactive Server use?

    • ALong polling only
    • BA SignalR connection (WebSockets when available)
    • CgRPC
    • DServer-Sent Events only
    Show answer

    Answer: B. A SignalR connection (WebSockets when available)

    UI events and DOM diffs travel over the circuit.

  7. Which directive sets the render mode on a component?

    • A@mode
    • B@rendermode
    • C@interactive
    • D@render
    Show answer

    Answer: B. @rendermode

    For example @rendermode InteractiveServer.

  8. Which component renders a form with validation support?

    • A<form>
    • B<EditForm>
    • C<FormView>
    • D<InputForm>
    Show answer

    Answer: B. <EditForm>

    EditForm creates an EditContext for the model.

  9. Which component enables Data Annotations validation inside EditForm?

    • A<Validator />
    • B<DataAnnotationsValidator />
    • C<ValidationSummary /> alone
    • D<ModelValidator />
    Show answer

    Answer: B. <DataAnnotationsValidator />

    ValidationSummary and ValidationMessage then display the errors.

  10. Which method should a component call to re-render after an external event?

    • ARefresh()
    • BStateHasChanged()
    • CRender()
    • DUpdate()
    Show answer

    Answer: B. StateHasChanged()

    Use InvokeAsync(StateHasChanged) when called from another thread.

  11. Which lifecycle method runs once when the component is first initialised?

    • AOnParametersSet
    • BOnInitializedAsync
    • COnAfterRender
    • DDispose
    Show answer

    Answer: B. OnInitializedAsync

    It may run twice when prerendering is enabled.

  12. How does a child notify its parent?

    • AA static event
    • BAn EventCallback parameter
    • CChanging the parent’s field
    • DJavaScript interop
    Show answer

    Answer: B. An EventCallback parameter

    The parent passes a handler and the child calls InvokeAsync.

  13. Which component shares a value with all descendants?

    • A<CascadingValue>
    • B<Provider>
    • C<Context>
    • D<Shared>
    Show answer

    Answer: A. <CascadingValue>

    Descendants receive it with [CascadingParameter].

  14. Which interface calls JavaScript from C#?

    • AIJSRuntime
    • BIJavaScript
    • CIBrowser
    • DIJsInterop
    Show answer

    Answer: A. IJSRuntime

    await JS.InvokeVoidAsync("alert", "Hi").

  15. When is JS interop safe in an Interactive Server component?

    • AIn the constructor
    • BIn OnInitialized during prerendering
    • CIn OnAfterRenderAsync
    • DAnywhere
    Show answer

    Answer: C. In OnAfterRenderAsync

    During prerendering there is no browser connection yet.

  16. Which component shows UI only to authenticated users?

    • A<Authorize>
    • B<AuthorizeView>
    • C<SecureView>
    • D<UserOnly>
    Show answer

    Answer: B. <AuthorizeView>

    It renders Authorized or NotAuthorized content.

  17. Why does this list flicker and lose input focus on update?

    Razor / Markup Illustrative
    @foreach (var item in Items)
    {
        <TodoRow Item="item" />
    }
    
    • ANothing is wrong
    • BItems have no @key, so Blazor cannot match elements to data
    • C@foreach is not allowed
    • DInputs cannot be in lists
    Show answer

    Answer: B. Items have no @key, so Blazor cannot match elements to data

    Add @key="item.Id" so elements are preserved.

  18. Which service creates short-lived DbContexts for components?

    • ADbContextPool
    • BIDbContextFactory<T>
    • CIServiceProvider only
    • DDbContextScope
    Show answer

    Answer: B. IDbContextFactory<T>

    Create one per operation with CreateDbContextAsync.

  19. Which component catches rendering exceptions in part of the UI?

    • A<ErrorBoundary>
    • B<TryCatch>
    • C<Fallback>
    • D<SafeView>
    Show answer

    Answer: A. <ErrorBoundary>

    It shows ErrorContent instead of crashing the whole app.

  20. Which component virtualises long lists?

    • A<Virtualize>
    • B<LazyList>
    • C<InfiniteList>
    • D<Paged>
    Show answer

    Answer: A. <Virtualize>

    Only visible rows are rendered.

  21. Which render mode keeps a SignalR connection open?

    • AStatic SSR
    • BInteractive Server
    • CInteractive WebAssembly
    • DNone
    Show answer

    Answer: B. Interactive Server

    Interactive Server handles UI events on the server over a SignalR connection.

    From the lesson: Blazor Web App
  22. Interactive Auto uses WebAssembly for the very first visit.

    • ATrue
    • BFalse
    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 App
  23. What file extension do Blazor components use?

    • A.cshtml
    • B.razor
    • C.blazor
    • D.cs only
    Show answer

    Answer: B. .razor

    Components are .razor files.

    From the lesson: Introduction to Blazor
  24. In a Blazor Web App, every page is interactive by default.

    • ATrue
    • BFalse
    Show answer

    Answer: B. False

    Pages use static server rendering unless an interactive render mode is applied.

    From the lesson: Introduction to Blazor
  25. Over what does Interactive Server send UI updates?

    • AWebAssembly
    • BA SignalR connection (circuit)
    • CServer-sent HTML pages
    • DService workers
    Show answer

    Answer: B. A SignalR connection (circuit)

    Interactive Server keeps a SignalR circuit per user.

    From the lesson: Blazor Architecture