Mern Stack Developer

filter-iconFilter interviews by

40+ Mern Stack Developer Interview Questions and Answers

Updated 17 Dec 2024

Popular Companies

search-icon

Q1. Middle of a Linked List

You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.

If there is an odd number of elements, return the middle ...read more

Ans.

Given the head node of a singly linked list, return a pointer to the middle node. If there are an odd number of elements, return the middle element. If there are even elements, return the one farther from the head node.

  • Traverse the linked list using two pointers, one moving one node at a time and the other moving two nodes at a time.

  • When the fast pointer reaches the end of the list, the slow pointer will be at the middle node.

  • If the number of elements is even, return the seco...read more

Q2. Huffman Coding Challenge

Given an array ARR of integers containing 'N' elements where each element denotes the frequency of a character in a message composed of 'N' alphabets of an alien language, your task is ...read more

Ans.

The task is to find the Huffman codes for each alphabet in an encoded message based on their frequencies.

  • The Huffman code is a binary string that uniquely represents each character in the message.

  • The total number of bits used to represent the message should be minimized.

  • If there are multiple valid Huffman codes, any of them can be printed.

  • The input consists of multiple test cases, each with an array of frequencies.

  • Implement the function to find the Huffman codes and return 1 ...read more

Mern Stack Developer Interview Questions and Answers for Freshers

illustration image

Q3. Trapping Rain Water Problem Statement

You are given a long type array/list ARR of size N, representing an elevation map. The value ARR[i] denotes the elevation of the ith bar. Your task is to determine the tota...read more

Ans.

The question asks to find the total amount of rainwater that can be trapped in the given elevation map.

  • Iterate through the array and find the maximum height on the left and right of each bar.

  • Calculate the amount of water that can be trapped at each bar by subtracting its height from the minimum of the maximum heights on the left and right.

  • Sum up the amount of water trapped at each bar to get the total amount of rainwater trapped.

Frequently asked in,

Q4. Path Reversals Problem Statement

You are provided with a directed graph and two nodes, 'S' and 'D'. Your objective is to determine the minimum number of edges that need to be reversed to establish a path from n...read more

Ans.

The task is to find the minimum number of edges that need to be reversed in a directed graph to find the path from a start node to an end node.

  • The problem can be solved using graph traversal algorithms like Breadth First Search (BFS) or Depth First Search (DFS).

  • Start by creating an adjacency list representation of the directed graph.

  • Perform a BFS or DFS from the start node to the end node, keeping track of the number of edges reversed.

  • Return the minimum number of edges revers...read more

Are these interview questions helpful?

Q5. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Ans.

The task is to find all distinct triplets in an array that add up to a given sum.

  • Iterate through the array and fix the first element of the triplet.

  • Use two pointers approach to find the other two elements that sum up to the remaining target.

  • Handle duplicates by skipping duplicate elements while iterating.

  • Return the list of valid triplets.

Frequently asked in,

Q6. Move Zeroes to End

Given an unsorted array of integers, rearrange the elements such that all the zeroes are moved to the end, while maintaining the order of non-zero elements.

Input:

The first line contains an ...read more
Ans.

Rearrange an unsorted array by moving all zeroes to the end while maintaining the order of non-zero elements.

  • Iterate through the array and keep track of the count of non-zero elements encountered.

  • While iterating, if the current element is non-zero, swap it with the element at the count index.

  • After iterating, fill the remaining elements with zeroes.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. Decode Ways Problem Statement

Given a string strNum that represents a number, the task is to determine the number of ways to decode it using the following encoding: 'A' - 1, 'B' - 2, ..., 'Z' - 26.

Input:

The f...read more
Ans.

The task is to determine the number of ways to decode a given number string using a specific encoding.

  • Iterate through the string and use dynamic programming to calculate the number of ways to decode at each position.

  • Consider different cases such as single digit decoding, double digit decoding, and invalid decoding.

  • Use modulo 10^9+7 to handle potentially large numbers of decode ways.

  • Example: For '226', there are 3 possible decodings: 'BZ', 'BBF', 'VF'.

Q8. Find First Repeated Character in a String

Given a string 'STR' composed of lowercase English letters, identify the character that repeats first in terms of its initial occurrence.

Example:

Input:
STR = "abccba"...read more
Ans.

Find the first repeated character in a given string composed of lowercase English letters.

  • Iterate through the string and keep track of characters seen so far in a set.

  • If a character is already in the set, return it as the first repeated character.

  • If no repeated character is found, return '%'.

Mern Stack Developer Jobs

MERN Stack Developer - React.js/Node.js (4-5 yrs) 4-5 years
Vegavid Technology Pvt. Ltd.
4.9
Mern Stack Developer 1-4 years
Petpooja
4.1
Ahmedabad
Lead MERN Stack Developer (7-12 yrs) 7-12 years
QUESS
3.9

Q9. What is the middleware used in redux? write syntax of it. Redux seletors.

Ans.

Redux middleware is a function that intercepts actions and can modify or dispatch new actions.

  • Middleware can be used for logging, error handling, and asynchronous actions.

  • Syntax: const middleware = store => next => action => { //middleware logic }

  • Redux selectors are functions that extract specific data from the Redux store.

  • Example: const getUserName = state => state.user.name;

Q10. What is the difference between a while loop and a for loop?

Ans.

While loop is used when the number of iterations is not known beforehand, while for loop is used when the number of iterations is known.

  • While loop checks a condition before each iteration, for loop has initialization, condition, and increment/decrement expressions.

  • For loop is more concise and easier to read for iterating over a range of values.

  • While loop is more flexible and can be used for situations where the number of iterations is not fixed.

  • Example: while loop - while(i <...read more

Q11. what is jwt token and difference between jwt token and bearer token

Ans.

JWT token is a JSON web token used for authentication and authorization. Bearer token is a type of access token that is used to authenticate API requests.

  • JWT token stands for JSON Web Token and is used for securely transmitting information between parties as a JSON object.

  • Bearer token is a type of access token that is used to authenticate API requests.

  • JWT token is self-contained and contains user information and metadata, while bearer token is simply a string that identifies ...read more

Q12. What is react-router-dom and whta's is working process?

Ans.

React-router-dom is a routing library for React applications.

  • It allows for declarative routing in React applications.

  • It provides components like BrowserRouter, Route, Switch, and Link.

  • BrowserRouter is used to wrap the entire application and provide routing functionality.

  • Route is used to define a route and the component to render when the route is accessed.

  • Switch is used to render only the first matching route.

  • Link is used to create links between different routes in the applic...read more

Q13. how multiple inheritance is made possible in java

Ans.

Java does not support multiple inheritance, but it can be achieved through interfaces.

  • Java does not allow multiple inheritance of classes due to the diamond problem.

  • However, multiple inheritance can be achieved through interfaces.

  • A class can implement multiple interfaces, which can have their own default implementations.

  • Example: class A implements Interface1, Interface2 { }

Q14. react js: architecture of context api and why to use redux.

Ans.

Context API provides a way to pass data through the component tree without having to pass props down manually. Redux is used for managing global state in complex applications.

  • Context API allows you to share data across components without having to pass props down manually

  • Redux is preferred for managing global state in large applications with complex data flow

  • Context API is simpler to use for smaller applications with less complex state management

  • Redux provides a centralized s...read more

Q15. What is the difference between NoSQL and SQL databases?

Ans.

NoSQL databases are non-relational databases that do not require a fixed schema, while SQL databases are relational databases that use structured query language.

  • NoSQL databases are schema-less, allowing for flexibility in data storage

  • SQL databases use structured query language to interact with data

  • NoSQL databases are horizontally scalable, making them suitable for big data applications

  • SQL databases are vertically scalable, typically running on a single server

  • Examples of NoSQL...read more

Q16. create product , perform curd opration , make the suggetion in this cart

Ans.

Create a product cart with CRUD operations and suggestion feature.

  • Create a database schema for products

  • Implement CRUD operations for adding, updating, and deleting products

  • Implement a suggestion feature based on user preferences or past purchases

Q17. what is difference between useState and useRef

Ans.

useState is used to manage state in functional components, while useRef is used to persist values between renders.

  • useState is used for managing state in functional components and triggers re-renders when the state changes.

  • useRef is used to persist values between renders without triggering re-renders.

  • useState returns a tuple with the current state value and a function to update it, while useRef returns a mutable ref object.

  • Example: useState can be used to manage a counter in a...read more

Q18. Implement the file uploads system coding task multiselect file uplods

Ans.

Implementing a multiselect file upload system for a MERN stack application.

  • Use a library like Multer for handling file uploads in Node.js

  • Create a form in React with multiple file input fields for selecting multiple files

  • Send the selected files to the server using a POST request

  • Handle the file uploads on the server side and save them to a designated folder

Q19. explain the process of execption handling

Ans.

Exception handling is the process of handling errors and unexpected events in a program.

  • Exceptions are thrown when an error occurs in the program.

  • The try-catch block is used to handle exceptions.

  • The catch block catches the exception and handles it appropriately.

  • Finally block is used to execute code regardless of whether an exception was thrown or not.

  • Exception handling helps in making the program more robust and prevents it from crashing.

Q20. What is shared operator in mongodb?

Ans.

The $shared operator in MongoDB is used to perform set intersection between arrays.

  • Used to find common elements between arrays

  • Returns an array containing elements that appear in all input arrays

  • Syntax: { $shared: { arrays: [ , , ... ] } }

  • Example: { $shared: { arrays: [ [1, 2, 3], [2, 3, 4] ] } } returns [2, 3]

Q21. dsa problem : recursive solution of fibonacci series

Ans.

Fibonacci series can be solved recursively by adding the previous two numbers in the series.

  • Define a base case for when n is 0 or 1, return n in that case

  • Otherwise, recursively call the function with n-1 and n-2 and add the results

  • Example: Fibonacci(5) = Fibonacci(4) + Fibonacci(3) = Fibonacci(3) + Fibonacci(2) + Fibonacci(2) + Fibonacci(1) = 3 + 2 + 2 + 1 = 8

Q22. Feature of React using advanced and disadvantage

Ans.

React's advanced feature is virtual DOM for efficient rendering, but it can be complex for beginners.

  • Virtual DOM allows React to update only the necessary parts of the actual DOM, improving performance.

  • Advanced state management with tools like Redux or Context API.

  • Server-side rendering for better SEO and initial load performance.

  • Component-based architecture for reusability and maintainability.

  • Complex learning curve for beginners due to JSX syntax and component lifecycle metho...read more

Q23. What are different kinds of hooks

Ans.

Hooks are functions that let you use state and other React features without writing a class.

  • useState() - for managing state in functional components

  • useEffect() - for side effects in functional components

  • useContext() - for accessing context in functional components

  • useReducer() - alternative to useState() for more complex state logic

Q24. which tech stack you use previously

Ans.

I have previously used the MERN stack which includes MongoDB, Express.js, React, and Node.js.

  • MongoDB for database management

  • Express.js for building the backend server

  • React for building the frontend user interface

  • Node.js for server-side scripting

Q25. How to hash a password?

Ans.

To hash a password, use a secure hashing algorithm like bcrypt.

  • Use a secure hashing algorithm like bcrypt to hash the password.

  • Generate a salt to add to the password before hashing.

  • Hash the password using the bcrypt library function.

  • Store the hashed password and the salt securely in the database.

Q26. Create a full stack web app using react.

Ans.

A full stack web app using React

  • Set up a Node.js server with Express

  • Create a database using MongoDB

  • Build the frontend using React components

  • Connect frontend to backend using API calls

  • Implement user authentication and authorization

  • Deploy the app on a hosting platform like Heroku

Q27. What is react and tell its uses

Ans.

React is a JavaScript library for building user interfaces.

  • React allows developers to create reusable UI components.

  • It uses a virtual DOM for efficient rendering.

  • React can be used for building single-page applications.

  • React Native allows for building mobile applications using React.

  • React is maintained by Facebook and a community of developers.

Q28. Difference between ES6 and JavaScript?

Ans.

ES6 is a version of JavaScript with new features and syntax.

  • ES6 introduced let and const for variable declaration

  • Arrow functions were introduced in ES6

  • Template literals were introduced in ES6

  • ES6 introduced classes for object-oriented programming

  • ES6 introduced the spread operator and destructuring

  • JavaScript is the programming language, while ES6 is a version of it

Q29. Concept of Node js, Mongodb ?

Ans.

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine, MongoDB is a NoSQL database that uses a document-oriented data model.

  • Node.js is used for server-side scripting and building scalable network applications.

  • MongoDB is a NoSQL database that stores data in flexible, JSON-like documents.

  • Node.js and MongoDB are often used together in the MEAN/MERN stack for full-stack development.

  • Node.js allows for asynchronous programming, making it efficient for handling mult...read more

Q30. What's Components re-rendering

Ans.

Components re-rendering is the process of updating the UI when there is a change in the component's state or props.

  • React re-renders the component and its child components when there is a change in state or props

  • Re-rendering can be optimized using shouldComponentUpdate or React.memo

  • Re-rendering can cause performance issues if not optimized properly

Q31. how node handels concurrency

Ans.

Node.js uses an event-driven, non-blocking I/O model to handle concurrency.

  • Node.js uses an event loop to handle multiple requests concurrently.

  • It employs a single-threaded event loop that can handle thousands of concurrent connections.

  • Node.js uses non-blocking I/O operations, allowing it to efficiently handle multiple requests without blocking the execution of other code.

  • It utilizes callbacks and event emitters to handle asynchronous operations.

  • Node.js also provides the 'clus...read more

Q32. WHat is usememo use effect

Ans.

useMemo and useEffect are hooks in React used for optimizing performance and managing side effects respectively.

  • useMemo is used to memoize the result of a function and cache it for future use.

  • useEffect is used to perform side effects like fetching data, subscribing to events, or updating the DOM.

  • useMemo is used when you want to optimize expensive calculations or avoid unnecessary re-rendering.

  • useEffect is used when you want to perform actions after rendering or when certain d...read more

Q33. What is state and props

Ans.

State and props are two important concepts in React for managing data and passing data between components.

  • State is a built-in feature in React components that allows components to have their own internal data that can change over time.

  • Props (short for properties) are used to pass data from a parent component to a child component.

  • State is mutable and can be changed within the component, while props are read-only and cannot be changed within the component.

  • State is typically use...read more

Q34. How axios interceptor works

Ans.

Axios interceptor is a middleware that allows you to intercept requests or responses before they are handled by the application.

  • Axios interceptors can be used to modify requests or responses globally for all requests.

  • You can add interceptors to handle requests, responses, errors, and more.

  • Interceptors can be used for tasks like adding headers, logging, or handling authentication.

  • Example: axios.interceptors.request.use() for handling requests, axios.interceptors.response.use()...read more

Q35. Make stopwatch in react

Ans.

Create a stopwatch using React

  • Create a state variable to hold the time

  • Use setInterval to update the time every second

  • Render the time in the component

  • Add buttons to start, stop, and reset the stopwatch

Q36. What is pelindrome

Ans.

A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward.

  • Palindrome is a sequence of characters that reads the same backward as forward

  • Examples: 'racecar', 'level', 'deified', 'madam', 'civic'

  • Palindrome can also be a phrase or a number, such as 'A man, a plan, a canal, Panama!' or '121'

  • Palindrome is commonly used in programming to check if a string is the same when reversed

Q37. What is bodyparser in node

Ans.

bodyparser is a middleware used in Node.js to parse incoming request bodies

  • Used to parse incoming request bodies in Node.js

  • Helps in accessing the request body data in a more structured format

  • Commonly used with Express.js to handle POST requests

  • Example: app.use(bodyParser.urlencoded({ extended: true }))

  • Example: app.use(bodyParser.json())

Q38. HTML used for website create

Ans.

HTML is a markup language used to create the structure of a website.

  • HTML stands for HyperText Markup Language

  • It is used to create the structure of web pages by using tags

  • Tags are enclosed in angle brackets like <tag>

  • Example: <html>, <head>, <body>, <p>

Q39. How i connect api

Ans.

To connect an API, you can use libraries like Axios or Fetch to make HTTP requests and retrieve data from the API.

  • Use Axios or Fetch library to make HTTP requests to the API endpoint

  • Provide necessary headers, parameters, and authentication tokens when making the request

  • Handle the response data accordingly, such as parsing JSON data or handling errors

Q40. what is Closures

Ans.

Closures are functions that have access to their own scope, as well as the scope in which they were defined.

  • Closures allow functions to access variables from their parent function even after the parent function has finished executing.

  • They are commonly used in event handlers, callbacks, and for data privacy.

  • Example: function outerFunction() { let outerVar = 'I am outer'; return function innerFunction() { console.log(outerVar); }; }

Q41. Give some coding based code

Ans.

Provide coding based code for Mern Stack Developer interview

  • Use Node.js for backend development

  • Utilize Express.js for creating APIs

  • Implement React.js for frontend development

  • Use MongoDB for database management

Q42. Diff b/w sql / nosql

Ans.

SQL is a relational database management system, while NoSQL is a non-relational database management system.

  • SQL databases are table-based and have a predefined schema, while NoSQL databases are document-based, key-value pairs, graph databases, or wide-column stores.

  • SQL databases are good for complex queries and transactions, while NoSQL databases are better for hierarchical data storage.

  • Examples of SQL databases include MySQL, Oracle, and PostgreSQL, while examples of NoSQL da...read more

Q43. Write about microservices

Ans.

Microservices are a software development technique where applications are composed of small, independent services that communicate with each other.

  • Microservices break down applications into smaller, loosely coupled services that can be developed, deployed, and scaled independently.

  • Each microservice is responsible for a specific business function and communicates with other services through APIs.

  • Microservices promote flexibility, scalability, and resilience in software develop...read more

Q44. 4 lakh per annum

Ans.

The salary of 4 lakh per annum is below market average for a Mern Stack Developer.

  • Research the average salary for Mern Stack Developers in your area to negotiate for a higher salary.

  • Consider the cost of living in the area when evaluating the salary offer.

  • Factor in your experience, skills, and qualifications when determining your worth in the job market.

Q45. pipeline in express

Ans.

Pipeline in Express is a series of functions that are executed in a specific order during the request-response cycle.

  • Middleware functions are added to the pipeline using app.use() or app.METHOD() functions.

  • Each middleware function can modify the request and response objects, or end the request-response cycle.

  • Middleware functions can be used for tasks like logging, authentication, error handling, etc.

Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions for Mern Stack Developer Related Skills

Interview experiences of popular companies

3.6
 • 7.5k Interviews
3.7
 • 4.8k Interviews
3.8
 • 2.9k Interviews
4.0
 • 215 Interviews
3.3
 • 213 Interviews
3.6
 • 33 Interviews
3.0
 • 9 Interviews
5.0
 • 2 Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Recently Viewed
INTERVIEWS
Jamboree Education
No Interviews
LIST OF COMPANIES
Codestore Technologies
Overview
COMPANY BENEFITS
Codestore Technologies
No Benefits
REVIEWS
MulticoreWare
No Reviews
SALARIES
ThoughtSpot
INTERVIEWS
Precise Biopharma
No Interviews
INTERVIEWS
vSplash Techlabs
No Interviews
INTERVIEWS
Gharda Chemicals Limited
No Interviews
INTERVIEWS
Yara Fertilisers
No Interviews
REVIEWS
Codestore Technologies
No Reviews
Mern Stack Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter