Node.
js is a cross-platform environment and library for running JavaScript applications which is used
to create networking and server-side applications.
Note that each question is followed by the correct answer and an explanation to help reinforce your
knowledge.
1. What is Node.js?
A. A front-end framework
B. A back-end framework
C. A JavaScript runtime built on Chrome's V8 JavaScript engine
D. A type of database
Click to View Answer and Explanation
Answer:
C. A JavaScript runtime built on Chrome's V8 JavaScript engine
Explanation:
Node.js is not a framework; it's a runtime environment that allows JavaScript to be executed server-side.
2. Which package manager is bundled with Node.js by default?
A. npm
B. bower
C. yarn
D. grunt
Click to View Answer and Explanation
Answer:
A. npm
Explanation:
npm, which stands for Node Package Manager, comes bundled with Node.js and facilitates package
management.
3. How can you initiate a project using npm?
A. npm start
B. npm init
C. npm run
D. npm create
Click to View Answer and Explanation
Answer:
B. npm init
Explanation:
Using npm init, you can initialize a new project and create a package.json file.
4. Which method is used in Node.js to include modules?
A. require()
B. include()
C. import
D. fetch()
Click to View Answer and Explanation
5. Which core module in Node.js provides asynchronous file operations?
A. http
B. url
C. fs
D. path
Click to View Answer and Explanation
Answer:
C. fs
Explanation:
The fs module in Node.js is used for file operations, both synchronous and asynchronous.
6. In Node.js, which of the following is an in-built event emitter?
A. EventEmitter
B. Events
C. EventLoop
D. EventYield
Click to View Answer and Explanation
Answer:
A. EventEmitter
Explanation:
EventEmitter is a part of the events module in Node.js and is used to handle custom events within apps.
7. Which global object provides functionality to control the Node.js runtime process?
A. Global
B. Runtime
C. Process
D. NodeControl
Click to View Answer and Explanation
Answer:
C. Process
Explanation:
The process global object provides information about and control over the Node.js runtime process.
8. How can you read command-line arguments in a Node.js application?
A. argv
B. process.args
C. arguments
D. process.argv
Click to View Answer and Explanation
Answer:
D. process.argv
Explanation:
The process.argv property returns an array containing command-line arguments passed to the Node.js
process.
9. Which method is used to create a new instance of a server in Node.js?
A. http.createServer()
B. http.createInstance()
C. http.newServer()
D. http.createServerInstance()
Click to View Answer and Explanation
Answer:
A. http.createServer()
Explanation:
The http.createServer() method from the http module is used to create a new server instance in Node.js.
10. Which of the following is a core module for handling paths?
A. url
B. dir
C. path
D. location
Click to View Answer and Explanation
Answer:
C. path
Explanation:
The path module provides utilities for working with file and directory paths.
11. What does the stream module in Node.js provide?
A. Tools for creating WebSockets
B. Utilities for handling HTTP operations
C. A way to handle streaming data
D. Functions for dealing with promises
Click to View Answer and Explanation
Answer:
C. A way to handle streaming data
Explanation:
The stream module provides the capability to handle streaming data, like reading from or writing to files
in a continuous manner.
12. What is the Node.js event loop?
A. A loop that emits custom events
B. A loop that continuously checks for events and processes them
C. A mechanism to define custom events
D. The main process of a Node.js application
Click to View Answer and Explanation
Answer:
B. A loop that continuously checks for events and processes them
Explanation:
The event loop in Node.js continuously checks the event queue and processes events (like function
callbacks), allowing Node.js to be non-blocking and asynchronous.
13. Which utility allows you to automatically restart a Node application when changes are detected?
A. NodeLive
B. NodeReload
C. Nodemon
D. AutoNode
Click to View Answer and Explanation
Answer:
C. Nodemon
Explanation:
Nodemon is a utility that monitors for any changes in your Node application and automatically restarts
the server, making development more efficient.
14. What is a buffer in Node.js?
A. A temporary storage spot for data being transferred
B. A type of variable
C. A mechanism to control data flow
D. A module for handling binary data
Click to View Answer and Explanation
Answer:
A. A temporary storage spot for data being transferred
Explanation:
In Node.js, a buffer is a temporary storage location for raw data before it gets processed or transferred to
a different location.
15. Which Node.js method is used to delay the execution of a function?
A. process.delay()
B. setTimeout()
C. wait()
D. sleep()
Click to View Answer and Explanation
Answer:
B. setTimeout()
Explanation:
setTimeout() is a global method in Node.js (and in browsers) used to execute a function after a set
number of milliseconds.
16. Which of the following allows Node.js to be scalable?
A. Multithreading
B. Event-driven architecture
C. Larger memory allocation
D. High CPU usage
Click to View Answer and Explanation
Answer:
B. Event-driven architecture
Explanation:
Node.js's event-driven, non-blocking I/O model allows it to be lightweight and efficient, making it
scalable for real-time applications that run across distributed devices.
17. What is the main difference between exports and module.exports in Node.js?
A. They are the same.
B. exports is for functions, while module.exports is for objects.
C. exports is a reference to module.exports.
D. module.exports is the legacy way to export modules.
Click to View Answer and Explanation
Answer:
C. exports is a reference to module.exports.
Explanation:
Both exports and module.exports point to the same object. However, if you reassign exports, it no longer
references module.exports.
18. What would be the primary use case for the cluster module in Node.js?
A. Data validation
B. Improved logging
C. Load balancing over multiple CPU cores
D. Data encryption
Click to View Answer and Explanation
Answer:
C. Load balancing over multiple CPU cores
Explanation:
The cluster module allows Node.js applications to run on multiple CPU cores, ensuring better load
balancing and improved application performance.
19. Which of the following is NOT a core module in Node.js?
A. fs
B. http
C. express
D. url
Click to View Answer and Explanation
Answer:
C. express
Explanation:
While express is a popular module used in Node.js for web server operations, it is not a core module. It
has to be installed separately via npm.
20. Which method in the fs module is used to read a file asynchronously?
A. fs.readFile()
B. fs.readSync()
C. fs.openFile()
D. fs.read()
Click to View Answer and Explanation
Answer:
A. fs.readFile()
Explanation:
fs.readFile() is the asynchronous method used for reading files in Node.js.
21. In which object are all the environment variables stored in a Node.js application?
A. env
B. process.env
C. node.env
D. app.env
Click to View Answer and Explanation
Answer:
B. process.env
Explanation:
The process.env object contains the user environment in a Node.js application.
22. What does the eventEmitter.emit method in Node.js do?
A. It sets up a new event.
B. It triggers an event.
C. It listens for an event.
D. It terminates an ongoing event.
Click to View Answer and Explanation
Answer:
B. It triggers an event.
Explanation:
eventEmitter.emit is used to trigger or emit a particular event.
23. How do you install a package locally using npm in a Node.js application?
A. npm install -g <package-name>
B. npm local install <package-name>
C. npm run install <package-name>
D. npm install <package-name>
Click to View Answer and Explanation
Answer:
D. npm install <package-name>
Explanation:
Using npm install <package-name> installs the package locally in the node_modules directory of the
current project.
24. In a Node.js application, which method is used to send a JSON response back from a server?
A. res.json()
B. res.sendJSON()
C. res.returnJSON()
D. res.pushJSON()
Click to View Answer and Explanation
Answer:
A. res.json()
Explanation:
In Express (a popular framework for Node.js), res.json() is used to send a JSON response to the client.
25. What does the npm init command do?
A. It installs all the dependencies listed in package.json.
B. It starts the Node.js application.
C. It creates a new Node.js application.
D. It initializes a new package.json file.
Click to View Answer and Explanation
Answer:
D. It initializes a new package.json file.
Explanation:
npm init is used to set up a new or existing npm package, primarily creating a package.json file.
26. Which of the following is used to import modules in Node.js?
A. import { module } from 'module-name'
B. #include 'module-name'
C. require('module-name')
D. using module-name
Click to View Answer and Explanation
Answer:
C. require('module-name')
Explanation:
In Node.js, the require function is used to import modules.
27. Which npm command is used to install all dependencies listed in the package.json file?
A. npm init
B. npm run
C. npm start
D. npm install
Click to View Answer and Explanation
Answer:
D. npm install
Explanation:
The npm install command installs all the dependencies listed in the package.json file.
28. Which Node.js command is used to execute a JavaScript file, say "app.js"?
A. node install app.js
B. node run app.js
C. node app.js
D. npm app.js
Click to View Answer and Explanation
Answer:
C. node app.js
Explanation:
To execute a file, you simply use the node followed by the filename.
29. What is the purpose of the --save flag in the npm install command?
A. To globally install a package
B. To save a backup of the current project
C. To save the package version in the package-lock.json
D. To save the package in the package.json dependencies
Click to View Answer and Explanation
Answer:
D. To save the package in the package.json dependencies
Explanation:
The --save flag is used to add the installed module to the package.json file's dependencies.
30. Which npm command can be used to list all globally installed packages?
A. npm list -g
B. npm global list
C. npm show
D. npm modules
Click to View Answer and Explanation
Answer:
A. npm list -g
Explanation:
The command npm list -g displays all globally installed npm packages.
DevOps Quiz - Multiple Choice Questions (MCQ)
Author: Ramesh Fadatare
DevOps MCQ
Welcome to the DevOps Quiz! This blog post consists of over 20 multiple-choice questions that cover key
concepts of DevOps, from the foundational principles to the popular tools used in a typical DevOps
pipeline. Each question is followed by its correct answer and a succinct explanation that not only justifies
the answer but also provides additional context or trivia.
1. What does 'DevOps' stand for?
a) Development Operations
b) Device Operations
c) Deviant Operations
d) Developer's Operations
Click to View Answer and Explanation
Answer:
a) Development Operations
Explanation:
DevOps combines "Development" and "Operations", emphasizing collaboration between developers and
IT operations teams.
2. Which tool is commonly used for Continuous Integration and Continuous Deployment (CI/CD)?
a) Jenkins
b) Docker
c) Git
d) Ansible
Click to View Answer and Explanation
Answer:
a) Jenkins
Explanation:
Jenkins is a widely used open-source tool that facilitates both Continuous Integration and Continuous
Deployment.
3. What does CI in CI/CD stand for?
a) Continuous Input
b) Continuous Integration
c) Continuous Improvement
d) Continuous Installation
Click to View Answer and Explanation
Answer:
b) Continuous Integration
Explanation:
CI stands for Continuous Integration, a practice where developers integrate code into a shared repository
frequently.
4. Which of the following is NOT a configuration management tool?
a) Chef
b) Puppet
c) Ansible
d) Jira
Click to View Answer and Explanation
Answer:
d) Jira
Explanation:
While Chef, Puppet, and Ansible are configuration management tools, Jira is an issue and project tracking
tool.
5. What is Docker primarily used for?
a) Version Control
b) Continuous Integration
c) Containerization
d) Project Management
Click to View Answer and Explanation
Answer:
c) Containerization
Explanation:
Docker is primarily known for creating, deploying, and running applications in containers.
6. What's the primary purpose of Kubernetes?
a) Source code management
b) Automated testing
c) Container orchestration
d) Configuration management
Click to View Answer and Explanation
Answer:
c) Container orchestration
Explanation:
Kubernetes is a platform designed to manage containerized workloads and services.
7. Which tool is mainly used for version control in DevOps?
a) Jenkins
b) Docker
c) Kubernetes
d) Git
Click to View Answer and Explanation
Answer:
d) Git
Explanation:
Git is a distributed version control system commonly used in the DevOps world.
8. What does IaC stand for in DevOps?
a) Infrastructure as Computer
b) Integration and Configuration
c) Infrastructure as Code
d) Input and Compute
Click to View Answer and Explanation
Answer:
c) Infrastructure as Code
Explanation:
IaC or Infrastructure as Code is a method to provision and manage IT infrastructure through code and
automation.
9. Which of the following is a benefit of implementing DevOps?
a) Slower release cycles
b) Less collaboration between teams
c) Reduced recovery time after failures
d) Increased infrastructure cost
Click to View Answer and Explanation
Answer:
c) Reduced recovery time after failures
Explanation:
DevOps practices like CI/CD allow for quicker detection and recovery from errors, reducing downtime.
10. In DevOps, what does "shift left" refer to?
a) Delaying testing to the end of the development cycle
b) Incorporating operations earlier in the development cycle
c) Left-aligning code
d) Outsourcing operations
Click to View Answer and Explanation
Answer:
b) Incorporating operations earlier in the development cycle
Explanation:
"Shift left" emphasizes incorporating testing and other operations earlier in the software development
process.
11. Which of the following represents a cultural aspect of DevOps?
a) Using Docker
b) Automation scripts
c) Collaboration and sharing between teams
d) Writing Infrastructure as Code
Click to View Answer and Explanation
Answer:
c) Collaboration and sharing between teams
Explanation:
While tools and automation play a role in DevOps, its foundation lies in fostering a culture of
collaboration and transparency between development and operations teams.
12. What is Infrastructure as Code (IaC)?
a) Writing scripts (code) to automate infrastructure deployment
b) Using code repositories to store infrastructure information
c) Documenting infrastructure requirements
d) Writing application code that supports multiple infrastructure setups
Click to View Answer and Explanation
Answer:
a) Writing scripts (code) to automate infrastructure deployment
Explanation:
Infrastructure as Code (IaC) involves managing and provisioning infrastructure through machine-
readable definition files, automating the process.
13. In which phase are automated tests primarily run in a CI/CD pipeline?
a) Build
b) Test
c) Deploy
d) Monitor
Click to View Answer and Explanation
Answer:
b) Test
Explanation:
In a CI/CD pipeline, once the code is built (compiled and packaged), it moves to the testing phase, where
automated tests are executed.
14. What does the acronym "CALMS" stand for in the context of DevOps?
a) Code, Automation, Logs, Monitoring, Security
b) Culture, Automation, Lean, Measurement, Sharing
c) Continuous Application Lifecycle Management System
d) Code, Automation, Lifecycle, Monitoring, Systems
Click to View Answer and Explanation
Answer:
b) Culture, Automation, Lean, Measurement, Sharing
Explanation:
CALMS represents the five pillars of DevOps – Culture, Automation, Lean, Measurement, and Sharing.
15. Which tool is used for configuration management?
a) Git
b) Nagios
c) Ansible
d) Jira
Click to View Answer and Explanation
Answer:
c) Ansible
Explanation:
Ansible is a popular tool for configuration management, automating tasks such as software configuration
and deployment.
16. Which practice involves deploying code into a production-like environment before actual
production?
a) Continuous Testing
b) Canary Release
c) Blue-Green Deployment
d) Continuous Deployment
Click to View Answer and Explanation
Answer:
c) Blue-Green Deployment
Explanation:
Blue-Green Deployment involves two parallel environments - Blue (current production) and Green (clone
of production). New code is deployed to the Green environment and, once tested and verified, traffic is
switched to it.
17. What is a Version Control System (VCS) primarily used for?
a) Infrastructure monitoring
b) Configuration management
c) Tracking changes to source code
d) Application deployment
Click to View Answer and Explanation
Answer:
c) Tracking changes to source code
Explanation:
A VCS like Git allows developers to track and manage changes to source code, facilitating collaboration
and version management.
18. Which tool is often used for orchestrating cloud infrastructure as code?
a) Jenkins
b) Grafana
c) Terraform
d) Docker
Click to View Answer and Explanation
Answer:
c) Terraform
Explanation:
Terraform is a widely-used tool for defining and providing cloud infrastructure using a declarative
configuration language. It enables Infrastructure as Code (IaC) practices for cloud resources.
19. Which term describes a method where developers merge their changes back to the main branch
multiple times a day?
a) Continuous Deployment
b) Continuous Integration
c) Continuous Monitoring
d) Continuous Feedback
Click to View Answer and Explanation
Answer:
b) Continuous Integration
Explanation:
Continuous Integration (CI) is a DevOps practice where developers integrate code into a shared
repository several times a day. It encourages more frequent code integrations and testing.
20. Which of the following tools is primarily associated with monitoring and visualizing time-series
data?
a) Ansible
b) Git
c) Grafana
d) Puppet
Click to View Answer and Explanation
Answer:
c) Grafana
Explanation:
Grafana is an open-source platform for monitoring and observability. It's commonly used to visualize
metrics from time-series databases.
21. What does the term "Immutable Infrastructure" refer to?
a) Infrastructure that can be easily changed and adapted
b) Infrastructure components that are never updated once deployed
c) Frequently changing infrastructure
d) Infrastructure that is resistant to hacker attacks
Click to View Answer and Explanation
Answer:
b) Infrastructure components that are never updated once deployed
Explanation:
Immutable Infrastructure refers to an approach where once infrastructure components are deployed,
they are never modified. Instead, if changes are needed, new instances are created to replace the old
ones.
22. Which DevOps practice involves automating the provisioning and management of servers?
a) Continuous Monitoring
b) Continuous Feedback
c) Configuration Management
d) Continuous Testing
Click to View Answer and Explanation
Answer:
c) Configuration Management
Explanation:
Configuration Management involves the use of tools and practices to automate the provisioning and
management of servers, ensuring that they maintain the desired state over time.
23. Which DevOps tool is known for its "Infrastructure as Code" capabilities and agentless
architecture?
a) Jenkins
b) Git
c) Puppet
d) Ansible
Click to View Answer and Explanation
Answer:
d) Ansible
Explanation:
Ansible is known for its Infrastructure as Code capabilities, allowing automation of cloud provisioning,
configuration management, and application deployments. It operates on an agentless architecture,
communicating via SSH or WinRM.
React.js has gained immense popularity among developers due to its efficiency, reusability, and
performance. If you're a React.js enthusiast or want to assess your knowledge of this JavaScript library,
this quiz is for you. This quiz consists of 15+ multiple-choice questions designed to test your
understanding of React.js concepts and best practices. Let's dive in and see how well you fare!
Learn React JS: React JS Tutorial for Beginners
Check out 100+ quiz questions: 100+ Quiz Questions to Test Your Java, Spring Boot, Microservices,
Hibernate, REST API Skills
1. What is React.js?
a) A JavaScript framework for building user interfaces.
b) A server-side programming language.
c) A database management system.
d) A front-end CSS framework.
Click to View Answer and Explanation
Answer:
a) A JavaScript framework for building user interfaces.
Explanation:
React.js is a JavaScript library, not a framework, that is primarily used for building user interfaces (UIs). It
allows developers to create reusable UI components and efficiently update the UI based on data
changes.
2. What does JSX stand for?
a) JavaScript XML
b) Java Syntax Extension
c) JSON Xchange Schema
d) JavaScript Xerography
Click to View Answer and Explanation
Answer:
a) JavaScript XML
Explanation:
JSX stands for JavaScript XML. It is an extension to JavaScript that allows you to write HTML-like syntax
within your JavaScript code in React.js. JSX makes it easier to define the structure and layout of
components.
3. Which lifecycle method is invoked immediately after a component is rendered on the DOM?
a) componentDidMount
b) componentDidUpdate
c) componentWillMount
d) componentWillRender
Click to View Answer and Explanation
Answer:
a) componentDidMount
Explanation:
The componentDidMount lifecycle method is invoked immediately after a component is rendered on the
DOM. It is commonly used to fetch data from an API, set up event listeners, or perform any necessary
initialization tasks.
4. What is the purpose of the "key" prop in React?
a) It uniquely identifies a component in an array of components.
b) It determines the visual styling of a component.
c) It specifies the route for navigation within a React application.
d) It defines the data type of a component's prop.
Click to View Answer and Explanation
Answer:
a) It uniquely identifies a component in an array of components.
Explanation:
The "key" prop is used to provide a unique identifier to each component in an array of components.
React uses this key to efficiently update and reconcile the components' virtual DOM when their positions
or states change.
5. What is the state of React class component?
a) A JavaScript method for sorting arrays.
b) A built-in object that stores component data.
c) A CSS class used for component styling.
d) A React component's initial render method.
Click to View Answer and Explanation
Answer:
b) A built-in object that stores component data.
Explanation:
State is a built-in object in React that allows components to store and manage data. It represents the
current state of a component and can be updated using the setState() method.
6. Which method is used to update the state of a class component in React?
a) this.updateState()
b) this.setState()
c) this.modifyState()
d) this.changeState()
Click to View Answer and Explanation
Answer:
b) this.setState()
Explanation:
The this.setState() method is used to update the state of a component in React. It accepts a new state
object or a function that returns a new state based on the previous state.
7. What is the purpose of the React Router library?
a) To handle HTTP requests in React applications.
b) To manage and synchronize component states.
c) To manage navigation and routing in React applications.
d) To optimize the performance of React applications.
Click to View Answer and Explanation
Answer:
c) To manage navigation and routing in React applications.
Explanation:
The React Router library provides a routing solution for React applications. It allows developers to define
routes, handle navigation, and render specific components based on the current URL.
8. What is the purpose of PropTypes in React?
a) To define the expected data types of component props.
b) To validate HTML syntax within JSX code.
c) To handle form validation in React applications.
d) To provide default values for component props.
Click to View Answer and Explanation
Answer:
a) To define the expected data types of component props.
Explanation:
PropTypes is a mechanism in React for specifying the expected data types of component props. It helps
ensure that the correct data types are passed to components and provides runtime warnings in case of
type mismatches.
9. What is the purpose of React Fragments?
a) To group multiple components within a single parent component.
b) To create reusable CSS styles for React components.
c) To optimize the rendering performance of React components.
d) To handle asynchronous operations in React applications.
Click to View Answer and Explanation
Answer:
a) To group multiple components within a single parent component.
Explanation:
React Fragments allow you to group multiple components within a single parent component without
introducing additional DOM elements. It helps avoid unnecessary wrapper divs and improves the
component hierarchy.
10. Which method is used to render a React component to the DOM?
a) renderComponent()
b) ReactDOM.render()
c) React.render()
d) component.render()
Click to View Answer and Explanation
Answer:
b) ReactDOM.render()
Explanation:
The ReactDOM.render() method is used to render a React component to the DOM. It takes the
component and a target DOM element as arguments and renders the component's output to the
specified element in the DOM.
11. What is the purpose of Redux in React applications?
a) To handle form validation and submission.
b) To manage and synchronize component states.
c) To define the expected data types of component props.
d) To create reusable UI components.
Click to View Answer and Explanation
Answer:
b) To manage and synchronize component states.
Explanation:
Redux is a state management library commonly used with React to manage and synchronize component
states in large-scale applications. It provides a predictable state container and facilitates unidirectional
data flow.
12. What is the significance of the virtual DOM in React?
a) It renders components on the server side.
b) It optimizes React components for mobile devices.
c) It provides an in-memory representation of the DOM for efficient updates.
d) It handles animations and transitions in React applications.
Click to View Answer and Explanation
Answer:
c) It provides an in-memory representation of the DOM for efficient updates.
Explanation:
The virtual DOM in React is an in-memory representation of the actual DOM. It allows React to efficiently
update and reconcile changes in the UI by comparing the virtual DOM with the real DOM and updating
only the necessary elements.
13. Which hook is used to add state to functional components in React?
a) useState
b) useEffect
c) useContext
d) useReducer
Click to View Answer and Explanation
Answer:
a) useState
Explanation:
The useState hook is used to add state to functional components in React. It allows you to declare a
state variable and provides a way to update its value. useState hook returns an array with the current
state value and a function to update the state.
14. What is the purpose of the useEffect hook in React?
a) To add state to functional components.
b) To handle component re-renders.
c) To perform side effects in functional components.
d) To handle form submissions in React applications.
Click to View Answer and Explanation
Answer:
c) To perform side effects in functional components.
Explanation:
The useEffect hook is used to perform side effects in functional components. Side effects can include
things like fetching data, subscribing to events, or manually updating the DOM. useEffect is called after
every render and can be used to manage the side effects of a component.
15. What is the purpose of the useParams hook in React Router?
a) To handle form validation in React.js
b) To retrieve query parameters from the URL
c) To extract URL parameters from a route
d) To manage the state of route transitions
Click to View Answer and Explanation
Answer:
c) To extract URL parameters from a route
Explanation:
The useParams hook in React Router is used to extract URL parameters from a route. URL parameters are
dynamic parts of the URL that can be accessed and used within a component to customize its behavior
based on the specific route.
16. How can you access form input values in React.js?
a) By using the document.getElementById() method
b) By using the event.target.value property
c) By using the useState hook and setting the initial value
d) By using the useRef hook and the current property
Click to View Answer and Explanation
Answer:
b) By using the event.target.value property
Explanation: