Node
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
D. A type of database
Answer:
Explanation:
Node.js is not a framework; it's a runtime environment that allows JavaScript to be executed server-side.
A. npm
B. bower
C. yarn
D. grunt
Answer:
A. npm
Explanation:
npm, which stands for Node Package Manager, comes bundled with Node.js and facilitates package
management.
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.
A. require()
B. include()
C. import
D. fetch()
A. http
B. url
C. fs
D. path
Answer:
C. fs
Explanation:
The fs module in Node.js is used for file operations, both synchronous and asynchronous.
A. EventEmitter
B. Events
C. EventLoop
D. EventYield
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
Answer:
C. Process
Explanation:
The process global object provides information about and control over the Node.js runtime process.
A. argv
B. process.args
C. arguments
D. process.argv
Answer:
D. process.argv
Explanation:
The process.argv property returns an array containing command-line arguments passed to the Node.js
process.
A. http.createServer()
B. http.createInstance()
C. http.newServer()
D. http.createServerInstance()
A. http.createServer()
Explanation:
The http.createServer() method from the http module is used to create a new server instance in Node.js.
A. url
B. dir
C. path
D. location
Answer:
C. path
Explanation:
The path module provides utilities for working with file and directory paths.
Answer:
Explanation:
The stream module provides the capability to handle streaming data, like reading from or writing to files
in a continuous manner.
Answer:
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
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.
B. A type of variable
Answer:
Explanation:
In Node.js, a buffer is a temporary storage location for raw data before it gets processed or transferred to
a different location.
B. setTimeout()
C. wait()
D. sleep()
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.
A. Multithreading
B. Event-driven architecture
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?
Answer:
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
D. Data encryption
Answer:
Explanation:
The cluster module allows Node.js applications to run on multiple CPU cores, ensuring better load
balancing and improved application performance.
A. fs
B. http
C. express
D. url
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.
A. fs.readFile()
B. fs.readSync()
C. fs.openFile()
D. fs.read()
Click to View Answer and Explanation
Answer:
A. fs.readFile()
Explanation:
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
Answer:
B. process.env
Explanation:
B. It triggers an event.
Answer:
B. It triggers an event.
Explanation:
23. How do you install a package locally using npm in a Node.js application?
Answer:
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()
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.
Answer:
Explanation:
npm init is used to set up a new or existing npm package, primarily creating a package.json file.
C. require('module-name')
D. using module-name
Answer:
C. require('module-name')
Explanation:
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
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"?
C. node app.js
D. npm app.js
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
Answer:
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
C. npm show
D. npm modules
Answer:
A. npm list -g
Explanation:
The command npm list -g displays all globally installed npm packages.
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
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
Answer:
a) Jenkins
Explanation:
Jenkins is a widely used open-source tool that facilitates both Continuous Integration and Continuous
Deployment.
a) Continuous Input
b) Continuous Integration
c) Continuous Improvement
d) Continuous Installation
Answer:
b) Continuous Integration
Explanation:
CI stands for Continuous Integration, a practice where developers integrate code into a shared repository
frequently.
a) Chef
b) Puppet
c) Ansible
d) Jira
Answer:
d) Jira
Explanation:
While Chef, Puppet, and Ansible are configuration management tools, Jira is an issue and project tracking
tool.
a) Version Control
b) Continuous Integration
c) Containerization
d) Project Management
Answer:
c) Containerization
Explanation:
Docker is primarily known for creating, deploying, and running applications in containers.
b) Automated testing
c) Container orchestration
d) Configuration management
Answer:
c) Container orchestration
Explanation:
a) Jenkins
b) Docker
c) Kubernetes
d) Git
Answer:
d) Git
Explanation:
Git is a distributed version control system commonly used in the DevOps world.
a) Infrastructure as Computer
c) Infrastructure as Code
Answer:
c) Infrastructure as Code
Explanation:
IaC or Infrastructure as Code is a method to provision and manage IT infrastructure through code and
automation.
Answer:
Explanation:
DevOps practices like CI/CD allow for quicker detection and recovery from errors, reducing downtime.
c) Left-aligning code
d) Outsourcing operations
Answer:
Explanation:
"Shift left" emphasizes incorporating testing and other operations earlier in the software development
process.
a) Using Docker
b) Automation scripts
Answer:
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.
Answer:
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
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?
Explanation:
CALMS represents the five pillars of DevOps – Culture, Automation, Lean, Measurement, and Sharing.
a) Git
b) Nagios
c) Ansible
d) Jira
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
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.
a) Infrastructure monitoring
b) Configuration management
d) Application deployment
Answer:
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
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
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
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.
Answer:
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
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
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!
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.
Answer:
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.
a) JavaScript XML
d) JavaScript Xerography
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
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.
Answer:
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.
Answer:
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.
a) this.updateState()
b) this.setState()
c) this.modifyState()
d) this.changeState()
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.
Answer:
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.
Answer:
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.
Answer:
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.
a) renderComponent()
b) ReactDOM.render()
c) React.render()
d) component.render()
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.
Answer:
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.
Answer:
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.
a) useState
b) useEffect
c) useContext
d) useReducer
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.
Answer:
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.
Answer:
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.
Answer:
Explanation: