InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
Mention types of streams? |
|
Answer» The following are the types of streams in Node.Js: 1) Readable Streams: A stream where you can recieve data but cannot send it. When you push data into a readable stream , it is buffered, until customer starts to read the data Example: HTTP REQUESTS to the server. Based on the HTTP request, server sends HTTP response to the client which is a readable stream. Another example is RSS FEED posted by remote SERVERS on the HTTP clients are readonly streams. Module used: fs.createReadStream 2) Writable Streams: A stream where you can send the data but not recieve from it. Example: user entered data on HTTP clients go as HTTP Responses to the server where data is written. Module used: fs.createWriteStream() 3) Duplex Streams: Streams that are both readable and writable. Example: TCP sockets Module used: net.socket 4) Transform Streams: A type of duplex streams where output is in someway related to the input. LIKE duplex streams, Transform streams also implement both Readable and Writable interfaces. |
|
| 52. |
What are streams? |
|
Answer» Streams are a way handling following:
It is the movement of data from one point to another. When a program is supposed to read a FILE consisting of single page(three to four lines), it will be initially read into memory from start to FINISH and then starts processing. If the file is an e-book consisting of 500+ pages , then it takes lot of storage SPACE and TIME to be LOADED into memory, before started processing. This is where Streams make a difference. Using streams, you read it piece by piece , processing its content without keeping it in memory. The following are the advantages of streams
The following code statement refer to stream module const stream = require(‘Stream’); |
|
| 53. |
Name the type of applications where you can use Node.js? |
Answer»
|
|
| 54. |
Name any three features of Node.js? |
|
Answer» Here is the list of important features of Node.JS
|
|
| 55. |
Who uses Node.js? |
|
Answer» Microsoft, Paypal, Uber
|
|
| 56. |
Name the applications where you cannot use Node.js? |
|
Answer» It is not advisable to use Node.js for CPU intensive applications Because node.js is designed AROUND using a single thread very EFFICIENTLY. Its event based model dispatches code fragments when specific events occur. Those code fragments are supposed to execute very quickly and then return CONTROL to node.js, which then dispatches the NEXT event. If one of those code fragments PERFORMS a long running task, then no more events will be dispatched and the whole system appears to hang. |
|
| 57. |
What is Node.js? |
Answer»
For those coming from Java development background , here is the ANALOGY. |
|