Docsity

Certified Angular 8 Developer Practice Exam, Exams of Technology

Toggle sidebar
bg1
Certified Angular 8 Developer Practice Exam
Question 1. What property in the @NgModule decorator specifies which components, directives, and
pipes belong to the module?
A) imports
B) declarations
C) providers
D) exports
Answer: B
Explanation: The declarations property lists components, directives, and pipes that are part of the
module.
Question 2. Which Angular CLI command is used to create a new Angular project?
A) ng build
B) ng new
C) ng generate
D) ng serve
Answer: B
Explanation: The ng new command scaffolds a new Angular application.
Question 3. What is the purpose of platformBrowserDynamic in Angular bootstrapping?
A) Serves static files
B) Bootstraps the AppModule
C) Generates routing modules
D) Builds production bundles
Answer: B
Explanation: platformBrowserDynamic bootstraps the root AppModule to start the Angular app.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51

Partial preview of the text

Download Certified Angular 8 Developer Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. What property in the @NgModule decorator specifies which components, directives, and pipes belong to the module? A) imports B) declarations C) providers D) exports Answer: B Explanation: The declarations property lists components, directives, and pipes that are part of the module. Question 2. Which Angular CLI command is used to create a new Angular project? A) ng build B) ng new C) ng generate D) ng serve Answer: B Explanation: The ng new command scaffolds a new Angular application. Question 3. What is the purpose of platformBrowserDynamic in Angular bootstrapping? A) Serves static files B) Bootstraps the AppModule C) Generates routing modules D) Builds production bundles Answer: B Explanation: platformBrowserDynamic bootstraps the root AppModule to start the Angular app.

Question 4. Which property in @NgModule is used to make components available to other modules? A) imports B) exports C) declarations D) providers Answer: B Explanation: The exports property makes components, directives, and pipes available for use in other modules. Question 5. What is the recommended way to organize shared directives and pipes in Angular? A) Place in AppModule B) Place in CoreModule C) Place in SharedModule D) Place in RoutingModule Answer: C Explanation: SharedModule is designed for reusable directives, pipes, and components. Question 6. How do you import a feature module into an Angular application? A) Add to declarations B) Add to providers C) Add to imports D) Add to bootstrap Answer: C Explanation: Feature modules must be listed in the imports array of AppModule or another module.

A) The service is available only in the current module B) The service is tree-shakable C) The service is a singleton throughout the app D) The service is not injectable Answer: C Explanation: providedIn: 'root' creates a singleton service available application-wide. Question 11. Which change detection strategy can improve performance for pure components? A) Default B) OnPush C) Manual D) None Answer: B Explanation: OnPush only checks for changes when input references change, reducing checks. Question 12. How does Zone.js help Angular with change detection? A) It manages routing B) It intercepts async operations C) It builds bundles D) It compiles templates Answer: B Explanation: Zone.js detects async tasks and notifies Angular to run change detection. Question 13. Which method of ChangeDetectorRef marks a component for change detection? A) detectChanges

B) detach C) markForCheck D) reattach Answer: C Explanation: markForCheck schedules the component for checking in the next detection cycle. Question 14. Which lifecycle hook is called after Angular sets input properties of a component? A) ngOnInit B) ngOnChanges C) ngAfterViewInit D) ngOnDestroy Answer: B Explanation: ngOnChanges runs whenever input-bound properties change. Question 15. What is the primary purpose of ngOnInit lifecycle hook? A) Run after the constructor B) Perform component initialization C) Destroy the component D) Check for changes Answer: B Explanation: ngOnInit is used for initializing data and starting logic after creation. Question 16. Which lifecycle hook is called once after the component's view has been initialized? A) ngAfterViewInit B) ngDoCheck

D) [(ngModel)] Answer: D Explanation: [(ngModel)] combines property and event binding for two-way data flow. Question 20. What does *ngIf structural directive do? A) Loops over elements B) Conditionally renders elements C) Changes element styling D) Handles events Answer: B Explanation: *ngIf conditionally adds or removes an element from the DOM. Question 21. Which directive is used to iterate over a list in Angular templates? A) *ngIf B) *ngFor C) *ngSwitch D) ngStyle Answer: B Explanation: *ngFor iterates over an array and renders a template for each item. Question 22. How can you optimize *ngFor performance for large lists? A) Use trackBy function B) Use *ngIf C) Use ngClass D) Use async pipe

Answer: A Explanation: trackBy helps Angular identify items by unique keys, reducing re-renders. Question 23. Which directive is used for switch-case control in Angular templates? A) *ngIf B) *ngFor C) *ngSwitchCase D) ngClass Answer: C Explanation: *ngSwitchCase works with *ngSwitch for conditional rendering based on values. Question 24. How do you create a custom attribute directive in Angular? A) Use @Component B) Use @Directive C) Use @Injectable D) Use @Pipe Answer: B Explanation: @Directive decorator is used to define custom attribute directives. Question 25. Which decorator lets you listen to events on the host element in a directive? A) @HostListener B) @Input C) @Output D) @Inject Answer: A

Question 29. Which attribute is used for required field validation in Angular forms? A) minlength B) required C) pattern D) maxLength Answer: B Explanation: The required attribute checks that the field is not empty. Question 30. What module is needed for reactive forms? A) FormsModule B) ReactiveFormsModule C) CommonModule D) HttpClientModule Answer: B Explanation: ReactiveFormsModule provides classes for reactive form control and validation. Question 31. Which class represents a single form control in reactive forms? A) FormGroup B) FormControl C) FormArray D) NgForm Answer: B Explanation: FormControl manages the value and validation status of a single input element.

Question 32. How do you programmatically build a group of controls in reactive forms? A) FormControl B) FormGroup C) NgForm D) NgModel Answer: B Explanation: FormGroup is used to group multiple FormControls together. Question 33. What is the purpose of FormArray in reactive forms? A) Group controls by key B) Manage an array of controls C) Validate a single field D) Bind a form to a model Answer: B Explanation: FormArray handles a dynamic array of FormControls or FormGroups. Question 34. How do you create a custom synchronous validator in Angular? A) Return an Observable B) Return a function that returns ValidationErrors or null C) Use async pipe D) Use @HostListener Answer: B Explanation: Synchronous validators return either a map of errors or null if valid. Question 35. How can you implement an asynchronous validator in Angular forms?

B) The injection scope C) The type of provider D) The form module Answer: B Explanation: providedIn determines the scope (root, platform, or module) where the service is available. Question 39. Which provider type allows you to use a factory function for service creation? A) Value provider B) Class provider C) Factory provider D) Alias provider Answer: C Explanation: Factory providers use a factory function to create the dependency. Question 40. How do you provide a configuration object using Angular DI? A) Use @Input B) Use InjectionToken C) Use @Output D) Use @HostListener Answer: B Explanation: InjectionToken allows injection of non-class dependencies like config objects. Question 41. What is the primary role of data services in Angular? A) Manage routing B) Handle HTTP requests and data sharing

C) Handle form validation D) Render templates Answer: B Explanation: Data services fetch, manipulate, and share data across components. Question 42. How do you ensure a service is a singleton throughout the application? A) Provide in each component B) Use providedIn: 'root' C) Use @Component D) Provide in each module Answer: B Explanation: providedIn: 'root' ensures a single instance of the service app-wide. Question 43. What is the key difference between Observables and Promises? A) Observables are synchronous B) Promises support multiple values C) Observables support multiple emissions over time D) Promises are used for routing Answer: C Explanation: Observables can emit multiple values, while Promises resolve once. Question 44. How do you prevent memory leaks with subscriptions in Angular? A) Forget to unsubscribe B) Use takeUntil or async pipe C) Use *ngIf

Answer: B Explanation: HttpClientModule provides HTTP services for requests and responses. Question 48. Which method is used to send a POST request with HttpClient? A) get B) post C) put D) delete Answer: B Explanation: post method sends data to the server via HTTP POST. Question 49. How do you inject an authentication token into every HTTP request? A) Use a service B) Use HTTP Interceptor C) Use ngIf D) Use ngModel Answer: B Explanation: HTTP Interceptors can modify requests, such as adding tokens. Question 50. Which method allows programmatic navigation in Angular routing? A) routerLink B) router.navigate() C) ngIf D) ngClass Answer: B

Explanation: router.navigate() changes routes programmatically in code. Question 51. What is the purpose of RouterModule.forRoot()? A) Configure feature routes B) Configure app-level routes C) Import FormsModule D) Provide HTTP services Answer: B Explanation: forRoot configures application-wide routes. Question 52. Which path matching strategy matches the entire URL? A) prefix B) full C) wildcard D) none Answer: B Explanation: full matches the entire path, not just the beginning. Question 53. How do you implement lazy loading for a feature module? A) Use forRoot() B) Use loadChildren in route config C) Use import statement D) Use ngIf Answer: B Explanation: loadChildren is used in route configuration for lazy loading.

Question 57. Which Angular CLI command compiles and serves the app locally? A) ng build B) ng serve C) ng test D) ng e2e Answer: B Explanation: ng serve compiles the app and starts a local development server. Question 58. What tool is used to analyze bundle size in Angular? A) Jasmine B) source-map-explorer C) ng serve D) HttpClient Answer: B Explanation: source-map-explorer visually analyzes generated bundle sizes. Question 59. What is the benefit of Ahead-of-Time (AOT) compilation? A) Quicker builds B) Smaller bundles and faster rendering C) Code splitting D) Hot module replacement Answer: B Explanation: AOT compiles templates before runtime, improving speed and reducing size. Question 60. What command builds the app for production?

A) ng build B) ng build --prod C) ng serve D) ng test Answer: B Explanation: ng build --prod optimizes the app for deployment. Question 61. How does the async pipe help with Observables in templates? A) It unsubscribes automatically B) It transforms values C) It triggers HTTP requests D) It creates Observables Answer: A Explanation: The async pipe subscribes and unsubscribes automatically, preventing memory leaks. Question 62. What does the TestBed.configureTestingModule method do in unit tests? A) Compiles and runs the app B) Sets up a testing environment C) Creates HTTP requests D) Analyzes bundles Answer: B Explanation: TestBed.configureTestingModule initializes the module for isolated component testing. Question 63. Which testing utility simulates asynchronous passage of time? A) fakeAsync and tick