Docsity

Certified Angular 7 Developer Practice Exam, Exams of Technology

Toggle sidebar
bg1
Certified Angular 7 Developer Practice Exam
Question 1. Which TypeScript feature allows you to specify the shape of objects?
A) Classes
B) Interfaces
C) Modules
D) Decorators
Answer: B
Explanation: Interfaces define the structure of objects in TypeScript, enforcing type safety.
Question 2. What does the Angular CLI command `ng new my-app` do?
A) Builds the application
B) Initializes a new Angular workspace and project
C) Starts the development server
D) Generates a new component
Answer: B
Explanation: `ng new` initializes a new Angular project with default configuration and files.
Question 3. In Angular, which file configures build options and environments?
A) package.json
B) angular.json
C) tsconfig.json
D) environment.ts
Answer: B
Explanation: The `angular.json` file manages build options, environments, and budgets for Angular
projects.
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 7 Developer Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which TypeScript feature allows you to specify the shape of objects? A) Classes B) Interfaces C) Modules D) Decorators Answer: B Explanation: Interfaces define the structure of objects in TypeScript, enforcing type safety. Question 2. What does the Angular CLI command ng new my-app do? A) Builds the application B) Initializes a new Angular workspace and project C) Starts the development server D) Generates a new component Answer: B Explanation: ng new initializes a new Angular project with default configuration and files. Question 3. In Angular, which file configures build options and environments? A) package.json B) angular.json C) tsconfig.json D) environment.ts Answer: B Explanation: The angular.json file manages build options, environments, and budgets for Angular projects.

Question 4. What is the purpose of the @NgModule decorator? A) Defines a component B) Specifies module metadata and configuration C) Creates a service D) Configures routing Answer: B Explanation: @NgModule is used to annotate classes as Angular modules and configure their declarations, imports, providers, and bootstrap components. Question 5. Which property in @NgModule metadata lists the components, directives, and pipes that belong to the module? A) imports B) providers C) declarations D) exports Answer: C Explanation: The declarations array includes all components, directives, and pipes belonging to the module. Question 6. What Angular feature enables loading modules only when needed to improve performance? A) Eager loading B) Lazy loading C) Bootstrap loading D) Static loading Answer: B Explanation: Lazy loading defers module loading until routes referencing the module are activated, improving initial load time.

Explanation: ngOnInit is called once after data-bound properties are initialized, suitable for fetching initial data. Question 10. Which syntax in a template represents one-way string interpolation? A) [property] B) (event) C) {{expression}} D) [(ngModel)] Answer: C Explanation: Double curly braces {{}} are used for one-way interpolation, displaying data as text. Question 11. How do you bind to an event in Angular templates? A) [event] B) (event) C) {{event}} D) *ngIf Answer: B Explanation: Parentheses (event) syntax binds Angular template events, e.g., (click) for click events. Question 12. What is required to use two-way data binding with ngModel? A) ReactiveFormsModule B) FormsModule C) HttpClientModule D) CommonModule Answer: B

Explanation: FormsModule must be imported to use two-way binding syntax [(ngModel)] in templates. Question 13. Which directive is used to repeat an element for each item in a list? A) *ngIf B) *ngSwitch C) *ngFor D) [ngClass] Answer: C Explanation: *ngFor is a structural directive that repeats elements for every item in an iterable. Question 14. How do you conditionally display elements in Angular templates? A) *ngIf B) [ngClass] C) *ngFor D) {{expression}} Answer: A Explanation: *ngIf removes or recreates elements in the DOM based on a condition. Question 15. Which Angular directive applies CSS classes dynamically? A) [ngStyle] B) [ngClass] C) *ngIf D) *ngFor Answer: B Explanation: [ngClass] binds CSS classes to an element based on an object or array expression.

Question 19. How do pure pipes differ from impure pipes? A) Pure pipes run only on reference changes, impure on every change detection B) Impure pipes run only on reference changes, pure on every change detection C) Both run on every change detection D) No difference Answer: A Explanation: Pure pipes are called only when input references change; impure pipes run with every change detection cycle. Question 20. Which decorator turns a class into an Angular service? A) @Directive B) @Injectable C) @Component D) @Pipe Answer: B Explanation: @Injectable marks a class as available for dependency injection as a service. Question 21. How can you ensure a service is singleton across the entire Angular app? A) Provide it in a component B) Provide it in the root module C) Use providedIn: 'root' D) Use providedIn: 'feature' Answer: C Explanation: providedIn: 'root' guarantees a single instance of the service throughout the application.

Question 22. Which provider type allows you to substitute a class with another implementation? A) useValue B) useClass C) useFactory D) useExisting Answer: B Explanation: useClass lets you specify an alternative implementation for a given token. Question 23. What is the main purpose of Angular's dependency injection system? A) Manage routing B) Manage component styles C) Manage instance creation and dependencies D) Handle HTTP requests Answer: C Explanation: Angular DI system automates dependency instantiation and management for classes. Question 24. How do you define basic routes in Angular? A) Using RouterModule.forRoot() B) Using @NgModule C) Using HttpClientModule D) Using FormsModule Answer: A Explanation: RouterModule.forRoot() sets up application-level routes. Question 25. What is the function of <router-outlet> in a template?

B) CanDeactivate C) Resolve D) CanLoad Answer: B Explanation: CanDeactivate checks if navigation away from a route should be allowed. Question 29. What is the main benefit of lazy loading feature modules in Angular? A) Reduces bundle size and speeds up initial load B) Makes routing easier C) Allows custom directives D) Improves template syntax Answer: A Explanation: Lazy loading splits application into smaller chunks, improving load time and performance. Question 30. What module must you import to use template-driven forms? A) ReactiveFormsModule B) FormsModule C) HttpClientModule D) RouterModule Answer: B Explanation: FormsModule enables template-driven forms and ngModel functionality. Question 31. Which directive binds form data bidirectionally in template-driven forms? A) ngForm B) ngModel

C) formControl D) ngClass Answer: B Explanation: ngModel enables two-way data binding for form fields. Question 32. How do you handle basic validation in template-driven forms? A) Using built-in HTML attributes (required, minlength, etc.) B) Writing custom pipes C) Using RxJS operators D) Using Angular Material Answer: A Explanation: Built-in validators like required and minlength are supported natively in Angular forms. Question 33. Which module is necessary for reactive forms? A) FormsModule B) ReactiveFormsModule C) CommonModule D) RouterModule Answer: B Explanation: ReactiveFormsModule provides reactive form building blocks like FormControl and FormGroup. Question 34. What is the role of FormBuilder in reactive forms? A) Handles HTTP communication B) Simplifies form creation with factory methods

C) ReactiveFormsModule D) BrowserModule Answer: B Explanation: HttpClientModule enables HTTP requests via the HttpClient service. Question 38. How do you perform a GET request in Angular? A) HttpClient.get(url) B) HttpClient.post(url) C) fetch(url) D) XMLHttpRequest Answer: A Explanation: HttpClient.get(url) fetches data from an API endpoint. Question 39. What RxJS operator is commonly used to handle HTTP errors? A) map B) catchError C) tap D) filter Answer: B Explanation: catchError intercepts and processes errors from HTTP requests. Question 40. Which feature allows you to modify outgoing HTTP requests globally? A) Router guards B) HTTP Interceptors C) Pipes

D) Directives Answer: B Explanation: HTTP Interceptors manipulate requests or responses across the entire app. Question 41. How do you create an HTTP interceptor in Angular? A) Implement the HttpInterceptor interface B) Extend HttpClient C) Use @Injectable D) Use @Directive Answer: A Explanation: Implementing HttpInterceptor interface allows custom logic on HTTP requests/responses. Question 42. What is an Observable in RxJS? A) A function that returns a promise B) A stream that can emit multiple values over time C) A static value D) A module Answer: B Explanation: Observables represent asynchronous data streams emitting multiple values. Question 43. How does a Subject differ from an Observable? A) Subjects can both emit and subscribe to values B) Observables can both emit and subscribe to values C) Subjects are only for HTTP requests D) No difference

Explanation: Observables can emit multiple values over time; Promises emit only one. Question 47. What is Angular Material? A) A set of CSS utilities B) A collection of pre-built UI components implementing Material Design C) An HTTP client D) A routing library Answer: B Explanation: Angular Material provides Material Design UI components for Angular apps. Question 48. What is CDK in Angular? A) Component Data Kit B) Component Development Kit C) Core Directive Kit D) Custom Directive Kit Answer: B Explanation: CDK is Component Development Kit, providing utilities for building custom UI components. Question 49. How do you implement virtual scrolling in Angular Material? A) Use *ngFor B) Use cdk-virtual-scroll-viewport C) Use [ngClass] D) Use <mat-scrollbar> Answer: B Explanation: cdk-virtual-scroll-viewport enables efficient list rendering with dynamic element loading.

Question 50. Which module allows drag-and-drop features in Angular? A) @angular/animations B) @angular/cdk/drag-drop C) @angular/forms D) @angular/router Answer: B Explanation: @angular/cdk/drag-drop provides drag-and-drop utilities for Angular. Question 51. Which testing framework is typically used with Angular CLI? A) Mocha B) Jasmine C) Jest D) QUnit Answer: B Explanation: Angular CLI uses Jasmine for unit testing by default. Question 52. What tool runs Angular unit tests in the browser? A) Protractor B) Karma C) Jest D) Jasmine Answer: B Explanation: Karma is the test runner used by Angular CLI to execute tests in browsers.

Question 56. Which decorator is used to create custom attribute directives? A) @Component B) @Directive C) @NgModule D) @Pipe Answer: B Explanation: @Directive creates custom directives for DOM manipulation. Question 57. How do you react to custom events in a child component? A) Using @Input() B) Using @Output() and EventEmitter C) Using @Pipe D) Using @NgModule Answer: B Explanation: @Output() and EventEmitter allow child components to emit events to parents. Question 58. Which property in @NgModule specifies the starting component? A) declarations B) providers C) bootstrap D) imports Answer: C Explanation: bootstrap lists the root component that Angular loads to launch the app. Question 59. How do you export components from a module for use in other modules?

A) Use declarations B) Use exports C) Use providers D) Use imports Answer: B Explanation: exports property allows components, directives, and pipes to be used in other modules. Question 60. What is the purpose of trackBy in *ngFor? A) Filters items B) Tracks item identity for efficient DOM updates C) Sorts items D) Applies CSS classes Answer: B Explanation: trackBy helps Angular track item identity, minimizing DOM changes during *ngFor iterations. Question 61. How do you bind multiple styles to an element dynamically? A) Use [ngClass] B) Use [ngStyle] C) Use *ngIf D) Use @Pipe Answer: B Explanation: [ngStyle] binds multiple inline styles based on an object or expression. Question 62. What does the providers array in @NgModule do?