Expressjs(Engineering > Computer Science And Engineering ) Questions and Answers

Question 1. What are core features of Express framework?
  1.    Allows to set up middlewares to respond to HTTP Requests
  2.    Defines a routing table which can works as per HTTP Method and URL
  3.    Dynamically render HTML Pages
  4.    All of the above
Explanation:-
Answer: Option D. -> All of the above





Question 2. How to store local variables that can be access within the application?
  1.    Using app.locals
  2.    Using app.storage
  3.    Using database
  4.    Config file
Explanation:-
Answer: Option A. -> Using app.locals





Question 3. What will be the output of the below code in the console?File: my_module.jsexports.name = 'Zeus'; Code:var my_module = require('./mymodule');console.log((function(settings){    return settings.split('').reverse().join('')})(my_module.name));
  1.    Error
  2.    Zeus
  3.    undefined
  4.    sueZ
Explanation:-
Answer: Option A. -> Error




Question 4. Where is captured values are populated regarding route parameters?
  1.    req.params object
  2.    app.locals object
  3.    req.data object
  4.    None of above
Explanation:-
Answer: Option A. -> req.params object





Question 5. Route paths, in combination with a request method, define the endpoints at which requests can be made. Which of following are valid form of route path?
  1.    strings
  2.    string patterns
  3.    regular expressions
  4.    All of above
Explanation:-
Answer: Option D. -> All of above





Question 6. What function arguments are available to Express.js Route handlers?
  1.    req - the request object
  2.    res - the response object
  3.    next
  4.    All of the above
Explanation:-
Answer: Option D. -> All of the above





Question 7. How can we create chainable route handlers for a route path in ExpressJS app?
  1.    Using app.route()
  2.    Using app.router()
  3.    Using app.routing()
  4.    All of these
Explanation:-
Answer: Option A. -> Using app.route()





Question 8. Imagine that you sent following ajax request:$.post("/process", {name:'john'}, function(data){    // Do some stuff}); What will be the answer from the server?Tip: On server side, we have the code which is given below Code:app.post('/process', function(req, res){    var data = '';     if(req.xhr){        data += 'One';    }     if(req.body.name){        data += 'Two';    }     res.send(data);});
  1.    OneTwo'
  2.    'One'
  3.    'Two'
  4.    All of these
Explanation:-
Answer: Option A. -> OneTwo'





Question 9. What are the commands are used to enable debugging in Express App?
  1.    Linux
  2.    Windows
  3.    Both A and B
  4.    None
Explanation:-
Answer: Option C. -> Both A and B





Question 10. In ExpressJS, the method app.all(path, callback [, callback ...]) can accept all HTTP methods
  1.    True
  2.    False
  3.    Insufficient data
  4.    None
Explanation:-
Answer: Option A. -> True