Loading

Quipoin Menu

Learn • Practice • Grow

angular / ngSwitch Directive
mcq
Direction: Choose the correct option

Q1.

What does `[ngSwitch]` directive do?
A. Creates a toggle button
B. Switches between multiple elements based on a condition
C. Toggles a switch
D. Handles routing
Direction: Choose the correct option

Q2.

How do you define a case in `ngSwitch`?
A. `ngSwitchCase`
B. `[ngSwitchCase]`
C. `case='value'`
D. `*ngSwitchCase='value'`
Direction: Choose the correct option

Q3.

What is the default case in `ngSwitch`?
A. `else`
B. `*ngSwitchDefault`
C. `default`
D. `otherwise`
Direction: Choose the correct option

Q4.

Consider: `
Red
Other
` with `color='blue'`. What renders?
A. Error
B. Other
C. Red
D. Nothing
Direction: Choose the correct option

Q5.

Can multiple `*ngSwitchCase` match simultaneously?
A. Yes, all matching cases render
B. An error occurs
C. Only the last match renders
D. No, only the first match renders
Direction: Choose the correct option

Q6.

What is the difference between `ngSwitch` and `*ngIf` chain?
A. `ngSwitch` is more efficient for multiple conditions on same element
B. They are the same
C. `*ngIf` is faster
D. `ngSwitch` is deprecated
Direction: Choose the correct option

Q7.

Can you use `ngSwitch` with strings?
A. Only enums
B. Yes, any type that can be compared
C. Only numbers
D. Only booleans
Direction: Choose the correct option

Q8.

What happens if no case matches and no default is provided?
A. An error occurs
B. Nothing is rendered
C. The first case renders
D. The last case renders
Direction: Choose the correct option

Q9.

How is `ngSwitch` syntax different from `*ngIf`?
A. `ngSwitch` uses `[ngSwitch]` and `*ngSwitchCase`; `*ngIf` is a single directive
B. They use same syntax
C. `ngSwitch` uses `*`
D. `*ngIf` uses brackets
Direction: Choose the correct option

Q10.

Can you use `ngSwitch` with `ngFor` on the same element?
A. Only with trackBy
B. Yes, combine them
C. Only with async pipe
D. No, use separate elements or `<ng-container>`