Purpose of Angular
Which statement best describes Angular as a framework for web development?
- A framework for building single-page web applications using components
- A relational database management system
- A CSS preprocessor for nesting and variables
- A desktop web browser
- A static site generator that produces only plain HTML with no client logic
Role of a Component
In Angular, what is the main purpose of a component in an app such as a simple to-do list?
- To encapsulate the view, logic, and styles for a part of the UI
- To maintain a persistent TCP connection to a server
- To compile scripts into machine code
- To store user passwords securely
- To manage low-level DOM APIs without templates
Interpolation
Which Angular feature lets you display a component property named title inside a template by writing {{ title }}?
- Interpolation
- Compilation
- Installation
- Isolation
- Intercession
Structural Directives
Which directive would you use to show a welcome message only when a boolean variable isLoggedIn is true?
- *ngIf
- *ngShow
- *ngRepeat
- *ngVisible
- *ngSwitchCase
Services and Dependency Injection
Why would you create a service and inject it into multiple components, such as a CartService used by both a product list and a checkout view?
- To share reusable data and business logic across components via dependency injection
- To render CSS styles more efficiently
- To guarantee zero network latency
- To automatically generate database schemas
- To replace the routing system with hard-coded URLs
Modules (NgModule)
What is the primary role of an Angular module (NgModule) in an application?
- To organize related components, directives, pipes, and providers into a cohesive block
- To schedule tasks on the operating system
- To manage browser cookies and local storage exclusively
- To compress images before upload
- To render server-side templates on a remote host
Routing Basics
In a single-page app with a home page and a details page, what does the Angular router enable?
- Navigating between views based on URL changes without a full page reload
- Encrypting URLs so users cannot see them
- Blocking network requests from third-party domains
- Automatically resizing images for mobile screens
- Compiling templates into server-side HTML only
Pipes for Display
When you need to format a date for display (for example, 2025-01-01 to Jan 1, 2025) without changing the underlying data, which Angular feature should you use?
- Pipe
- Guard
- Service
- Resolver
- Injector
Lifecycle Hooks
If you want to run initialization code after a component is created, such as loading initial items for a list, which lifecycle hook should you implement?
- ngOnInit
- ngOnDestroy
- ngAfterExit
- onCreate
- construct
Two-Way Binding
Which template syntax enables two-way data binding for a text input bound to a name property, so editing the input updates name and vice versa?
- [(ngModel)]
- [value]
- (input)
- {{ name }}
- [ngModel]