WorksheetsExpress and Angular Quiz
Total questions: 30
Worksheet time: 15mins
Which command is used to install Express in a Node.js project?
npm install express
npm add express
install express
npm get express
In Express, which method is used to define a route for a GET request?
app.route()
app.get()
app.post()
app.listen()
What is the purpose of the res.send() method in Express?
To retrieve data from the server
To send a response back to the client
To log requests
To initialize a server
In Angular, what is the main purpose of a component?
To manage data
To define the structure of a database
To control a part of the user interface
To handle routing
Which of the following is a built-in directive in Angular?
ngShow
ngSwitch
ngDisplay
ngForEach
How can you bind a component property to an HTML element in Angular?
Using ngModel
Using {{ }} syntax
Using [( )] syntax
Using @Input()
What does req.params access in an Express application?
HTTP headers
Route parameters
Query string parameters
Request body
Which Angular feature allows for bidirectional data flow?
Property Binding
Event Binding
Two-Way Binding
Interpolation
What is the purpose of ngFor in Angular?
To create multiple components
To loop through data in a collection
To conditionally include elements
To bind properties to elements
Which command is used to create a new Angular component using the CLI?
ng component my-component
ng generate component my-component
ng create component my-component
ng make component my-component
How do you serve static files in an Express application?
app.serveStatic('public')
app.use(express.static('public'))
app.static('public')
app.serve('public')
In Angular, what does the @Injectable() decorator do?
It defines a component
It specifies a service
It allows dependency injection for a class
It binds data to the template
What is the correct way to handle a POST request in Express?
app.get('/user', (req, res) => { ... })
app.post('/user', (req, res) => { ... })
app.put('/user', (req, res) => { ... })
app.delete('/user', (req, res) => { ... })
Which Angular directive would you use to conditionally display an element?
ngFor
ngIf
ngSwitch
ngHide
In Angular, which binding syntax is used for event binding?
{{ event }}
[event]
(event)
[(event)]
Which of the following correctly defines a route in an Angular application?
const routes = [ { path: 'home', component: HomeComponent } ];
const routes = [ { route: 'home', component: HomeComponent } ];
const routes = [ { path: 'home', component: 'HomeComponent' } ];
const routes = [ { url: 'home', component: HomeComponent } ];
What is the purpose of res.json() in Express?
To send a JSON response to the client
To convert a response to JSON format
To send a plain text response
To log data in JSON format
In Angular, what is the main benefit of using TypeScript?
It is easier to write than JavaScript
It provides static typing
It is faster than JavaScript
It has built-in support for Angular
Which statement best describes Angular’s data binding?
It allows synchronization between model and view
It only updates the view
It only updates the model
It does not support two-way communication
How do you access the query string parameters in Express?
req.body
req.query
req.params
req.headers
What does the ngStyle directive do in Angular?
Changes the structure of the DOM
Applies classes to an element
Adds or removes inline styles
Binds component properties
In Angular, what does the expression {{ user.name }} do?
It executes a function called user
It displays the value of the name property of the user object
It assigns a value to user.name
It creates a new variable called user
What is the purpose of middleware in Express?
To define routes
To process requests before reaching the route handlers
To send responses
To log errors
Which of the following is NOT a type of data binding in Angular?
Interpolation
Property Binding
Event Binding
Response Binding
What command starts an Angular application?
ng serve
ng start
ng run
ng launch
How can you conditionally apply CSS classes in Angular?
Using ngStyle
Using ngIf
Using ngClass
Using ngSwitch
In an Angular service, how is data typically retrieved from an API?
Using HttpClient
Using fetch()
Using a plain XMLHttpRequest
Using getData()
What does app.listen(port, () => { ... }) do in Express?
Initializes a database
Starts the server and listens for incoming requests on the specified port
Defines a new route
Sends a response to the client
How do you create a two-way data binding for an input field in Angular?
Using ngModel
Using @Input()
Using @Output()
Using {{ }}
In Angular, which lifecycle hook is called after Angular has initialized all data-bound properties of a directive?
ngOnInit
ngOnChanges
ngAfterViewInit
ngOnDestroy
