Loading

Quipoin Menu

Learn • Practice • Grow

angular / Route Parameters
mcq
Direction: Choose the correct option

Q1.

How do you define a route with an `id` parameter?
A. { path: 'user', component: UserComponent, param: 'id' }
B. { path: 'user/{id}', component: UserComponent }
C. { path: 'user/:id', component: UserComponent }
D. { path: 'user/id', component: UserComponent }
Direction: Choose the correct option

Q2.

How do you access route parameters in a component?
A. Inject ActivatedRoute and use `params` observable
B. Inject Router and use `router.params`
C. Both A and C
D. Use `route.snapshot`
Direction: Choose the correct option

Q3.

What is the difference between `paramMap` and `params`?
A. They are identical
B. `paramMap` is for query params
C. `paramMap` provides a map with methods like `get()`, `params` is an object
D. `params` is deprecated
Direction: Choose the correct option

Q4.

How do you access query parameters (e.g., `?page=1`)?
A. ActivatedRoute.queryParams or .queryParamMap
B. Router.params
C. ActivatedRoute.params
D. Router.queryParams
Direction: Choose the correct option

Q5.

What happens when you navigate to the same route with different parameters?
A. The component is re-used, and you need to subscribe to param changes
B. An error occurs
C. The page reloads
D. A new component instance is created
Direction: Choose the correct option

Q6.

How do you get a parameter from the snapshot?
A. `this.route.params.id`
B. Both A and C
C. `this.route.snapshot.params.id`
D. `this.route.snapshot.paramMap.get('id')`
Direction: Choose the correct option

Q7.

What is the data type of parameters from `paramMap.get()`?
A. Array
B. Object
C. String
D. Number
Direction: Choose the correct option

Q8.

How do you access multiple route parameters?
A. Separate subscriptions
B. Multiple snapshots
C. From the same `params` object, e.g., `params.id`, `params.name`
D. Different routes
Direction: Choose the correct option

Q9.

What is a matrix parameter in Angular routing?
A. Query parameters
B. Parameters in the URL like `/users;id=1;name=john`
C. Route parameters
D. Fragment parameters
Direction: Choose the correct option

Q10.

How do you access matrix parameters?
A. Using `queryParams`
B. Using `ActivatedRoute.params` (they are included)
C. Using `data`
D. Using `fragment`