0% found this document useful (0 votes)
7 views6 pages

Mock Ad

Uploaded by

selene6141744
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Mock Ad

Uploaded by

selene6141744
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1)if there is no query string passed from client, req.

query property will be

ANS:{}

2)Microservices promote

ANS:ALL of the above

3)Which of the following is a valid schema type in mongoose?

ANS:ALL of the above

4)Middleware function can make changes to request and response object

ANS:TRUE

5)Mthod helps in starting the HTTP server and listens for connections

ANS:Listen()

6)Mongodb stores data in ______ format

ANS:JSON

7)NodeJS is based on ____ JS engine

ANS:-V8

8)Assume a schema for with the name “BLOGSCHEMA” is created. How do we compile the schema with
model

ANS: var BLOG=mongoose.model(“Blog”,BlogSchema);module.exports=Blog;

9)Promises can return multiple values

ANS:False

10)________ abstracts from clients about microservices implementation

ANS:API Gateway

1.________ method is used to bundle the code in an object and allows it to be reused.

Ans. Export

2. The argument to createServer function of http module is____

Ans: server object

3. Which one is not the possible state if the Promise Object?

Ans. Accepted

4. What is the output of the below code:

let test=()=>{
return new Promise((resolve, reject)=>{

reject();

})

test()

.then(()=>console.log("Resolved"))

.catch(()=>console.log("Rejected"))

Ans: Rejected

5. Which of the following is equivalent for the below code but in a non-blocking way?

var contents=fs.readFileSync('/etc/hosts');

console.log(contents)

console.log('Doing something else');

Ans:

6.Middleware functions the express are functions that have access to the request object (req), to
response object(res), and the next function in the application’s request-response cycle

Ans: True

7. Which of the following is used to create an express application?

Ans: require('express')

8. Which of the below is TRUE about Express?

Ans: It helps in creating robust API’s quickly.

9. Which of these are the characteristic of middleware function of ExpressJS?

Ans:All of the above

10.Suchi, a backend developer is building API’s using NodeJS with Express. She would like to make use of
the images in the application provided by her organization which are maintained in the
folder/assets/images. Choose the correct syntax to make use of these images

Ans: app.use(express.static(path.join(__dirname,'/assets/images')));

11. Consider the below code and predict the output

var express=require('express')

app=new express();

app.get('student/:id',function(req,res){
res.render('student'+req.parmas.id);

})

Ans:

12. In Mongoose,_________ represents documents which can be saved and retrieved from our
database.

Ans: Mongoose Schema

13. Which of the below is NOT TRUE about mongoose?

Ans:Query is written in native SQL.

14. Choose the appropriate code snippet to be added below that retrieves books details from mongodb
and display on console:

var MongoClient = require(‘mongodb’).MongoClient{

MongoClient.connect('mongodb://localhost:27017',function(err,client){

if(err) throw err

var db=client.db('store')

//code to retrieve books details from mongodb and display on console

}}

Ans:db.collection(‘books’).find().toArray

15. Ritu wants to use mongoose for employee data insertion, which should also give appropriate error
messages and successful messages. From the given options identify valid way to achieve this?

Ans: app.save

16. Each microservices is _________and ____________

Ans: small and independent

17. RabbitMQ uses Advances Message Queuing Protocol (AMQP) protocol for messaging State true or
false

Ans: True

18. A synchronous communication between services involves_________ protocol

Ans: http

19. Which of the following describes about API gateway?


API gateway uses http protocol

API gateway’s are front faces of microservices


API gateway abstract from clients about microservices implementation

All of the above

Ans: All of the above

20. Match the following:

1. Resilient a.Less time to build, deploy, and test per each release

2.Agility b.Ability to grow and manage increased demand

3.Scalable c.Failures in a component don’t necessarily affect the rest of application

Ans: 1-c, 2-a, 3-b

1)which function is used to associate a middleware function in an express app?

ANS:app.use()

2)const.express= require(‘express’)

Const app=________

App.get(“/”,(req,res)=>res.send(“hello world”))

App._____(3000,()=>

Console.log(“example app listeneing on port 3000!”))

ANS:-express(),listen

3) which of the below is not true about mongoose

ANS:-Query is written in native SQL

4)such a backend developer is building API using NODE js with express.

ANS:-app.use(express.static(path.join(_dirname,’/assets/images’));

5)Microservices should run in their own process.

ANS:-True

6)What is the correct syntax to create EXPRESS application instance?

ANS:-var app= require(“express”);

Var exp=new app();

7)var mongodb = require(“mongodb”);

Var mongoclient = mongodb.MongoClient();

Const url = “mongodb://localhost:27017”;

Const dbName = testproject;


ANS:-const mongoURL =”mongodb://localhost:5000”;

8) which function is used to import modules in nodejs

ANS:-Require

9)Why node js is suitable for developing applications using microservices architural style?

ANS:-a)It can handle IO operations in a non blocking way

b)Less memory footprint and better performance

c)Node is multithreaded and hence handle concurrent requests easily

d)Microservices involve intensive computational tasks that node can handle efficiency

10)which of the below is a feature of microservices architecture?

ANS:It follows single responsibility principle

11)Ritu want to use mongoose….etc?

ANS:-emp.create(function(err){

If(err){

Console.log(err);

}else{

Console.log(“Employee saved successfully!”);

}});

12)which of the following describes about writing middleware function in express?

ANS:- All the above

13)_____method helps in starting the HTTP server and listens for connections?

ANS:-listen()

14) const fs= require("fs")

const content = fs.readFileSync("sample.txt")


console.log(content.toString());
console.log("file read success");
let message="Node js is the runtime for JS and has modules"
fs.writeFileSync("nnotes.txt",message);
console.log("File written successfully");
console.log("end of the program");
ANS:-File read successfully

Fle written successfully


End of the program

15) let fs = require("fs");

console.log("1");
fs.readFile("sample.txt",'utf8',function(error,data){
if(error){
throw error;
}
console.log("2");
});
console.log("3");
ANS:-132

16)which of the following describes about API gateway?

ANS:-ALL the above

17)_____ is not a valid Http method

ANS:-header

18)which method is used to connect to the mongo database using mongoose?

ANS:-mongoose.connect()

19)what is the benefit of having single thread feature in Node JS?

ANS:

20) Asynchronous communication between microservices?

ANS:- promotes loose coupling.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy