Showing posts with label Angular mcq with answer. Show all posts
Showing posts with label Angular mcq with answer. Show all posts

Sunday, 10 January 2021

Angular MCQ : Angular Fundamentals : Part 5

(1) When filtering data, why should you create a copy of the data being filtered?

• To improve performance

• To improve performance

• In case you want to make edits to the data

• To maintain the order between page refreshes

• Otherwise you will lose data


(2) How do you specify where your routed components will appear in your application?

• They always appear just inside the <body> tag of your index.html.

• Use the <router-view> component.

• Use the <router-outlet> component.


(3) Once you have defined routes, how do make the router aware of them?

• Use RouterModule.forRoot or RouterModule.forChild in your Angular module.

• You don't need to make the router aware of them, declaring them as the data type "Routes" is sufficient.

• Import your routes file using a <script> tag in your index.html.

• Add the routes array to the declarations section of your module.


(4) What is the TestBed used for?

• Creating utilities for mocking services

• Integrating HTTP with Tests

• Creating mock child components

• Mimicking a Live Environment for Components


(5) What is Tree Shaking?

• An Optimization algorithm for binary searches

• A way to put multiple pieces of code together

• Automated removal of unused code


(6) When bootstrapping an Angular app, how do you specify the main Angular app module to load?

• Angular discovers the module based on the component that was bootstrapped.

• You load your module directly in your index.html file.

• You add your Angular module as a package in your SystemJs config.

• In your main SystemJs package (e.g. main.ts), you pass your app module into the platformBrowserDynamic.bootstrapModule() method,.


(7) When would you create a custom pipe?

• If you need to format an absolutely positioned node

• If you need to sort and filter your data

• If you need to have some business-specific formatting


(8) Which of the following is used as a container for components, services, directives, etc.?

• Dependency Injection

• An Angular Modules

• SystemJS


(9) Why would you use a setter on an @Input directive?

• To created a derived value on an Input value

• To validate the value of an Input

• To create a read-only input value


(10) How do you specify the html tag (e.g. <event-details>) to use for a component?

• You set the selector property in the component meta-data config.

• You set the tag property in the component meta-data config.

• You name the file that contains your component to match the tag name you want.

• You specify the tag name when declaring the component in your Angular module.


<<Angular Fundamentals part-4

Monday, 28 December 2020

Angular MCQ : Angular Fundamentals : Part 4

(1) What is the @ViewChild decorator used for?

• To add metadata for the children of a view

• The InjectionToken class To get a handle on a DOM node decorated with a ref tag(#ref_id)

• To make custom * directives


(2) An Observable represents what?

• Multiple values now

• Multiple values in the future

• Multiple values now or in the future


(3) Where should you sort and filter data?

• In your component

• In a directive

• In a filter


(3) Where should you sort and filter data?

• In your component

• In a directive

• In a filter


(4) Which decorator lets you inject a service registered with an Injection Token?

• Import

• Inject

• Input


(5) What directive helps you hide functionality you don’t want to be visible before users log in?

• ngHide

• ngShow

• ngIf

• ngAuthenticated


(6) Which decorator lets you inject a service registered with an Injection Token?

• Value comparison

• Deep value comparison

• Immutable comparison

• Mutable comparison

• Identity comparison


(7) Which of these would you use to toggle applying multiple classes to an element?

• Use a class binding

• Use a style binding

• Use ngClass


(8) What is the default token in Angular’s Dependency Injector?

• A string

• A class

• The Token class


(9) Which decorator lets you inject a service registered with an Injection Token?

• Import

• Inject

• Input


(10) Which decorator lets you inject a service registered with an Injection Token?

• Import

• Inject

• Input

 

<< Angular Fundamentals part-3      Angular Fundamentals part-5 >>

Sunday, 6 December 2020

Angular MCQ - Angular Fundamentals : Part 1

(1) What object allows you to create your own tokens?

• The Token class

• The InjectionToken class

• The TransparentToken class


(2) What does AOT stand for?

• Assertion of Test

• Android Operating Types

• Ahead of Time


(3) What is the best way to prevent a component from being loaded based on specific conditions?

• Check the condition in the component's constructor.

• Create a route guard and use the "canActivate" property of the component's route.

• Create a route resolver and use the "resolve" property of the component's route.


(4) A promise represents what?

• A single value in the future

• Multiple values in the future

• A single value in the present


(5) What is one way you can pass data from a child component to a parent component?

• You import the parent component into the child component.

• You add an @Input() property on the parent component and bind to it from the child component.

• You add an @Output() property on the child component and bind to it from the parent component.


(6) What does AAA stand for?

• Arrange Act Assert

• Act Arrange Assess

• Act Arrange Assert


(7) What is the main purpose of content projection? 

• Create reusable components with replaceable content

• Allow content to be shown in an overlay

• Improve performance


(8) Which of the following is a valid *ngFor expression?

• event of events

• let event in events

• let event of events


(9) Why does angular not ship with a filterBy or orderBy pipe?

• Those features are implemented in other pieces of the framework.

• To keep the download size small

• They can become performance issues.


(10) How do you inject a service into a component, directive, pipe, or another service?

• Import it and specify it as a parameter in the constructor decorated with the Inject() decorator.

• Import it and decorate the import with an Inject() decorator.

• Import it and specify it as a parameter in the constructor decorated with the Inject() decorator.