Open In App

Full Stack Developer Interview Questions and Answers

Last Updated : 31 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Full-stack developers are like web experts who can create and manage entire websites. This article contains many most asked questions and answers you might face in interviews for such jobs. It covers all the skills you should have such as HTML, CSS, JavaScript, GitHub, Node.js, MongoDB, PHP, Java, Python, and common interview questions.

Whether you’re experienced, or a fresher this article is a go-to guide to crack interviews for Full Stack Developer roles. This article is easy to understand, up-to-date, and very informative. Reading it can boost your chances of nailing your next dream interview.

Q1. What is an Iframe in HTML?
The iframe in HTML stands for Inline Frame. The ” iframe ” tag defines a rectangular region within the document in which the browser can display a separate document, including scrollbars and borders.

 

Syntax:

<iframe src="URL" title="description"></iframe>

Attributes value: It contains a single value URL that specifies the URL of the document that is embedded in the iframe. There are two types of URL links which are listed below:

  • Absolute URL: It points to another webpage.
  • Relative URL: It points to other files of the same web page.

Q2. What are Meta Tags and what are its uses?
Meta Tag(<meta>) is an HTML component that gives the metadata about an HTML document. MetaData can be characterized as data that gives the data of different information or basic information about information. It is an empty tag, for example, it just has an initial tag and no end tag. They are always present inside the <Head> tag and are utilized to portray Page portrayals, Certain Keywords, Author of the Document, viewport settings, determining character sets, and so on.

Syntax : 

<head>
<meta attribute-name = "value"/>
</head>

Attributes: The following attributes with their values are described below:

  • name: This attribute is used for indicating the character encoding for the HTML Document.
  • http-equiv: This attribute is used to get the HTTP response message header.
  • content: This attribute is used to specify property value.
  • charset: This is used for indicating the character encoding for the HTML Document.

Q3. What is the difference between properties and attributes in HTML?

Attribute Property
Attributes are defined by HTML. Properties are defined by the DOM.
The value of an attribute is constant. The value of a property is variable.
These are used to initialize the DOM properties. After initialization, the job is finish. 
 
No such job is finisheddefined.

Q4. Difference between <div> and <span> Tag in HTML

<div> <span>
The <div> tag is a block-level element. The <span> tag is an inline element.
It is best to attach it to a section of a web page. It is best to attach a CSS to a small section of a line in a web page.
It accepts align attributes. It does not accept the align attribute.
This tag should be used to wrap a section, for highlighting that section. This tag should be used to wrap any specific word that you want to highlight in your webpage.

Q5. Explain APIs Available in HTML5
API stands for Application Programming Interface. An API is a set of pre-built programs that can be used with the help of JavaScript. APIs are used to implement already written code to fulfill the needs of the project you are working on.

HTML Geolocation API: The Geolocation API is used to get the current location of the user or the page visitor.

Syntax:

var loc = navigator.geolocation;

Methods available in Geolocation API:

  • getCurrentPosition() Method: The getCurrentPosition() method returns an object with properties such as latitude, longitude, accuracy, altitude etc.
  • watchPosition() Method: This method will return the current position of the user as well as the updated location when the position of the user changes or the user travels from one location to another location.
  • clearWatch() Method: This method will stop the watchPosition() method to not tracing the user anymore.

HTML Drag and Drop API: Drag and Drop is a common feature nowadays, where you can drag an item from one place and drop it in another.

Syntax: To use drag and drop first you have to make the element draggable as shown below:

<div draggable="true">
//content of the element
</div>

HTML Web Storage API: HTML web storage API is used to store the data on the web browser. Early, the data was stored in the form of cookies that can store a small amount of data and cannot be transferred further to the server. But, HTML5 introduces us to the Web Storage API that can store large data as compared to cookies and can be transferred to the server. Using this API for storing data is more secure than using cookies.

Web storage API provides us with two objects to work with:

  • window.sessionStorage: This object temporarily stores the data on the web browser such that if the browser is refreshed or closed the data stored will be lost.
  • window.localStorage: localStorage permanently stores the data on the browser with no expiration such that will not be lost even if the browser is refreshed.

Q6. How to apply CSS styles to a web page ?
Cascading Style Sheet (CSS) is used to set the style in web pages that contain HTML elements. It sets the background color, font-size, font-family, color, … etc. properties of elements on a web page.

There are three types of CSS which are given below:

  • Inline CSS
  • Internal or Embedded CSS
  • External CSS

Q7. Explain how to define a variable in SASS
SASS variables can have only one value at a time, which means they can’t have different values of different elements. We can store the information related to numbers strings, lists, booleans, colors, and null in the SASS variables.

Sass Variables: 

  • Sass variables are declared once to store data that can be reused whenever required.
  • If you modify the variable value once, the changes are reflected in all places whenever the variables are used.
  • In Sass, we can store data in multiple types such as Numbers, Strings, booleans, lists, nulls, etc.

Syntax: 

$var_Name : var-value;

Q8. CSS Selectors
 A CSS selector selects the HTML element(s) for styling purposes. CSS selectors select HTML elements according to their id, class, type, attribute, etc.

Q9. What is the CSS clear property?

The clear property is used to specify which side of floating elements are not allowed to float. It sets or returns the position of the element in relation to floating objects. If the element can fit horizontally in the space next to another element that is floated, it will. 

Syntax:

clear: none|left|right|both|inline-start|inline-end|initial;

Q10. What is flexbox?

The flexbox or flexible box model in CSS is a one-dimensional layout model that has flexible and efficient layouts with distributed spaces among items to control their alignment structure ie., it is a layout model that provides an easy and clean way to arrange items within a container. Flexbox can be useful for creating small-scale layouts & is responsive and mobile-friendly.

Features of flexbox:

  • A lot of flexibility is given.
  • Arrangement & alignment of items.
  • Proper spacing

Q13. What is the CSS 2D Transforms
transformation in CSS is used to modify an element by its shape, size and position. It transforms the elements along the X-axis and Y-axis. There are 6 main types of transformation which are listed below:

  • translate()
  • rotate()
  • scale()
  • skewX()
  • skewY()
  • matrix()

Q14. Difference between RGB vs RGBA color format

RGB Color Format RGBA Color Format
RGB is a three-channel format containing data for Red, Green, and Blue. RGBA is a four-channel format containing data for Red, Green, Blue, and an Alpha value.
The CSS function rgb() has wide browser support. The CSS function rgba() may have limited support in the older browser.
The opacity of the color cannot be specified using this color format. The opacity of the color can be easily controlled by specifying the opacity in terms of a parameter.
Example: The rgb(0, 0, 255) defines blue color as its value is set to highest(255), while others are set as 0. Example: The rgba(255, 0, 0, 0.3) defines the red color with opacity set to 0.3.

Q15. What is Bootstrap Grid System?
Grid System: Bootstrap Grid System allows up to 12 columns across the page. You can use each of them individually or merge them together for wider columns. You can use all combinations of values summing up to 12. You can use 12 columns each of width 1, or use 4 columns each of width 3 or any other combination.

Q16. How to add badge to list group in Bootstrap ?
Badges are the number label that is associated with the link to indicate the number of items associated with the link. For instance, the notification number can be seen when logged in to a particular website which tells the numbers of new notifications to see by clicking on it.

Syntax:

<ul class="list-group">
<li class="list-group-item">
<span class="badge bg-type">Badge Content</span>
list-content
</li>
</ul>

Q17. How to use calc() in Tailwind CSS ?
The calc() is a built-in function in CSS that enables you to carry out mathematical computations. You can use the calc() function in Tailwind CSS to dynamically determine values for different CSS properties. You can use the “calc()” statement just by wrapping it inside square brackets. In this article, we will see the usage of the calc() function in Tailwind CSS.

Syntax:

calc(expression)

Parameter: The ‘expression” can include mathematical operations, values, and units.

Q18. How to align two elements left and right using tailwind CSS ?
You can easily float the elements to the left and right using Tailwind CSS. This can be done using either tailwind flex or flow-root classes.

Classes used:

  • flow-root: This class quickly clears floated content within a container by adding a flow-root utility.
  • position: This is used for controlling the placement of positioned elements.

Q19. What is an Alert component in Bootstrap?
The .alert class followed by contextual classes are used to display the alert message on website. The alert classes are: .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light and .alert-dark.

Syntax:

<div class="alert> Contents... <div>

Q20. Tailwind CSS Box Shadow
This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. By using this class we can control the box-shadow of an element. In CSS, we do that by using the CSS Shadow Effect properties of box-shadow. 

Box Shadow classes:

  • shadow-sm: This class is used to create a faded or small shadow effects on the box.
  • shadow: This class is used to create normal shadow effects on the box.
  • shadow-md: This class is used to create md effects on the box.

Syntax:

<element class="shadow-{shadow-depth}">...</element>

Q21. What is the purpose of the not-sr-only class in Tailwind CSS?
This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. This class is used to improving accessibility with screen readers. 

Screen Readers classes:

  • sr-only: This class is used to hide an element visually without hiding it from screen readers
  • not-sr-only: This class is used to undo the sr-only class effect.

Syntax:

<svg class="sr-only|not-sr-only">...</svg>

Q22. this keyword
JavaScript this keyword always holds the reference to a single object, which defines the current line of code’s execution context which means this keyword refers to the object that is currently executing the code. Functions in JavaScript, are essentially objects. 

There are various ways to set this in JavaScript:

  • Implicit Binding: When we call a function as a method of the object this keyword refers to the calling object
  • Explicit binding: When we explicitly bind this keyword using the call(), bind(), or apply() method then this keyword default reference is changed to the object called using the above-specified methods.
  • Default Binding: When this keyword is used in global scope this is set to window object.
  • Arrow Function Binding: When this is used in the arrow function then this has lexical scope so without the function keyword this is uanble to refer to the object in the outer scope. 

Q23. How does JavaScript .prototype work ?
 Every function has its properties prototype, these properties make it to the prototype of the function, so creating objects from this function by calling it in constructor mode whatever objects created will be the prototype of prototype template that means objects follow the template of prototype whatever properties or behaviour mention in prototype, objects will able to access those properties.

Q24. Difference between double equal vs triple equal JavaScript

  • Double equal: The double equal(‘==’) operator tests for abstract equality i.e. it does the necessary type conversions before doing the equality comparison.
  • Triple equal: The triple equal(‘===’) operator tests for strict equality i.e it will not do the type conversion hence if the two values are not of the same type, when compared, it will return false. 

Q25. What is promise?
JavaScript Promise are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback hell leading to unmanageable code. Prior to promises events and callback functions were used but they had limited functionalities and created unmanageable code. Multiple callback functions would create callback hell that leads to unmanageable code. Promises are used to handle asynchronous operations in JavaScript.

Syntax:

let promise = new Promise(function(resolve, reject){
//do something
});

Parameters

  • The promise constructor takes only one argument which is a callback function
  • The callback function takes two arguments, resolve and reject
    • Perform operations inside the callback function and if everything went well then call resolve.
    • If desired operations do not go well then call reject.

Q26. What is Event Bubbling and Capturing in JavaScript ?
Events are a fundamental construct of the modern web. They are a special set of objects that allow for signaling that something has occurred within a website. By defining Event listeners, developers can run specific code as the events happen. This allows for implementing complex control logic on a web application.

Q27. What are closures in JavaScript?
A closure is a feature of JavaScript that allows inner functions to access the outer scope of a function. Closure helps in binding a function to its outer boundary and is created automatically whenever a function is created.

Q28. What is a callback function in JavaScript ?
A callback is a function that is passed as an argument to another function, and is called after the main function has finished its execution. The main function is called with a callback function as its argument, and when the main function is finished, it calls the callback function to provide a result.

Q29. What is the use of the ‘use strict’ directive in JavaScript?
Strict Mode was a new feature in ECMAScript 5 that allows you to place a program, or a function, in a “strict” operating context. This strict context prevents certain actions from being taken and throws more exceptions

Benefits of using ‘use strict’: Strict mode makes several changes to normal JavaScript semantics. 

  • Strict mode eliminates some JavaScript silent errors by changing them to throw errors.
  • Strict mode fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that’s not strict mode.
  • Strict mode prohibits some syntax likely to be defined in future versions of ECMAScript.

How to use strict mode
Strict mode can be used in two ways, remember strict mode doesn’t work with block statements enclosed in {} braces. 

  • Used in global scope for the entire script.
  • It can be applied to individual functions.

Q30. Difference between var and let in JavaScript

var

let

The var is a keyword that is used to declare a variable The let is also a keyword that is used to declare a variable.

Syntax:

var name = value;

Syntax:

let name = value;

The variables that are defined with var statement have function scope. The variables that are defined with let statement have block scope.
We can declare a variable again even if it has been defined previously in the same scope. We cannot declare a variable more than once if we defined that previously in the same scope.
Hoisting is allowed with var. Hoisting is not allowed with let.

Example: var websitename = “geeksforgeeks”;

Example: let x = 69;

var is an ECMAScript1 feature. let is a feature of ES6.
Its supported browsers are: Chrome, Internet Explorer, Microsoft Edge, Firefox, safari, opera Its supported browsers are -: Chrome49, Microsoft Edge12, firefox44 , safari11, opera36

Q31. What are events ?
Javascript has events to provide a dynamic interface to a webpage. These events are hooked to elements in the Document Object Model(DOM). 
These events by default use bubbling propagation i.e, upwards in the DOM from children to parent. We can bind events either as inline or in an external script. 
Syntax:

<HTML-element Event-Type = "Action to be performed">

Q32. What is a polyfill ?
Polyfill is a way to modify or add new functions. It is basically a piece of code to add/modify the new functions. It is used to provide modern functionality to web browsers.

  • It is basically a piece of code to provide modern functionality to web browsers.
  • It is used to add/modify new functionalities.

Q33. What is Hoisting ?
Hoisting is a concept that enables us to extract values of variables and functions even before initializing/assigning value without getting errors and this happens during the 1st phase (memory creation phase) of the Execution Context.

Features of Hoisting:

  • In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution. Basically, it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local. 
  • It allows us to call functions before even writing them in our code. 

Note: JavaScript only hoists declarations, not initializations.

Q37. How to access history in JavaScript ?

History object: The history object contains the browser’s history. The URLs of pages visited by the user are stored as a stack in the history object. There are multiple methods to manage/access the history object.

Methods of History object:

1. The forward() Method: This method is used to load the next URL in the history list. This has the exact functionality as the next button in the browser. There are no parameters and it will return nothing.

Syntax:

history.forward()

2. The back() Method: This method is used to load the previous URL in the history list. This has the exact functionality as the back button in the browser. There are no parameters and it will return nothing.

Syntax:

history.back()

3. The go() Method: This method is used to loads a URL from the history list.

Syntax:

history.go(integer)

Q38. What is isNaN ?

The JavaScript isNaN() Function is used to check whether a given value is an illegal number or not. It returns true if the value is a NaN else returns false. It is different from the Number.isNaN() Method.

Syntax:

isNaN( value )

Parameter Values: This method accepts a single parameter as mentioned above and described below:

  • value: It is a required value passed in the isNaN() function.

Return Value: It returns a Boolean value i.e. returns true if the value is NaN else returns false.

Q39. Promise vs Callback in JavaScript

JavaScript Callback JavaScript Promise
The syntax is difficult to understand. The syntax is user-friendly and easy to read because of then and catch.
Error handling may be hard to manage. Error handling is easier to manage using catch block.
It may create callback hell. It resolves callback hell.

Q40. What is the preventDefault() Event Method ?

The preventDefault() method is used to prevent the browser from executing the default action of the selected element. It can prevent the user from processing the request by clicking the link.
Syntax:

event.preventDefault()

Parameters: It does not accept any parameter.
The event is used to denote the event or action by the user in the response of which the method works.

Q41. How to redirect to another webpage using JavaScript ?
The window.location object stores the location or URL of the page and we can redirect into another page using this window.location.

There are several methods to redirect to another webpage using JavaScript. Some of them are listed below:

Syntax:

location.href="URL"
or
location.replace("URL")
or
location.assign("URL")
  • Return Value: No return value.
  • Parameters: It accepts a single parameter URL which is required. It is used to specify the reference of the new webpage.

Q42. How do you trim a string in javascript ?
JavaScript String trim() method is used to remove the white spaces from both ends of the given string. 

Syntax:

str.trim()
  • Parameter: This method does not accept any parameter.
  • Return value: This method returns a new string, without any of the leading or trailing white spaces.

Q43. How to create multi-line strings in JavaScript ?
The multi-line strings were not supported by JavaScript 2015 but when ES6 came out and introduced string literals. The ES6 supports multi-line strings. There are various ways to handle multi-line strings if older browser support is essential.

Q44. What are the arrow functions in JavaScript?
Arrow functions are anonymous functions i.e. functions without a name and are not bound by an identifier. Arrow functions do not return any value and can be declared without the function keyword. They are also called Lambda Functions.

Syntax:

const gfg = () => {
console.log( "Hi Geek!" );
}

Q45. How to set default parameter value in JavaScript functions ?

In general all the JavaScript functions have a default value of undefined but we can overwrite it by specifying a particular value. This prevents breaking of the code in case of missing inputs.

Javascript




let multiplyIt = function (num1, num2) {
// So we are returning num1 times num2
return (num1 * num2);
};
  
console.log(multiplyIt());


Output

NaN

Q46. How to merge properties of two JavaScript objects dynamically?

Using Spread Operator: Spread operator allows an iterable to expand in places where 0+ arguments are expected. It is mostly used in the variable array where there is more than 1 values are expected. It allows the privilege to obtain a list of parameters from an array.

Javascript objects are key-value paired dictionaries. We can merge different objects into one using the spread (…) operator.
Syntax:

object1 = {...object2, ...object3, ... }

Javascript




let A = {
name: "geeksforgeeks",
};
  
let B = {
};
  
let Sites = { ...A, ...B };
  
console.log(Sites)


Output

{ name: 'geeksforgeeks', domain: 'https://geeksforgeeks.org' }




Q47. What is function-scoped?

Functions: Function allows us to declare & pack a bunch of code in a block so that we can use (and reuse) a block of code in our programs. Sometimes, they take some values as `parameters` to do the operation and return some value as a result of the operation.

Example:

Javascript




function add(a, b) {
  
// a and b are the parameters of this
// function code to do the operation
return a + b; // return statement
}
  
// Invoking the function and 2, 3
// are arguments here
console.log(add(2, 3));


Output

5

Q48. Difference Between Git and GitHub

Git GitHub
Git is a software. GitHub is a service.
Git is a command-line tool GitHub is a graphical user interface
Git is installed locally on the system GitHub is hosted on the web
Git is maintained by linux. GitHub is maintained by Microsoft.
Git is focused on version control and code sharing. GitHub is focused on centralized source code hosting.

Q49. What is Git stash?
Git stash: The Git stash command can be used to accomplish this if a developer is working on a project and wants to preserve the changes without committing them. This will allow him to switch branches and work on other projects without affecting the existing modifications. You can roll back modifications whenever necessary, and it stores the current state and rolls back developers to a prior state.

Q50. What is tagging in Git?
Tagging in GIT refers to creating specific points in the history of your repository/data. It is usually done to mark the release points.

Two main purposes of tags are:

  • Make Release point on your code.
  • Create historic restore points.

Q51. Difference Between Merging and Rebasing

Git Merge

Git Rebase

Git Merge merges two branches to create a “feature” branch. Git Rebase rebases the feature branch to add the feature branch to the main branch.
Git Merge is comparatively easy.  Git Rebase is comparatively harder.
Git Merge safeguards history. Git Rabse doesn’t safeguard history.
Git Merge is more suitable for projects with the less active main branch. Git Rebase is suitable for projects with frequently active main branches.
Git Merge forms a chain-like structure. Git Rebase forms a linear structure.
Git Merge is preferable for large no. of people working on a project. Git Rebase is preferable for small groups of people.

Q52. What is “git cherry-pick”?
Cherry-picking is just like rebasing, an advanced concept and also a powerful command. It is mainly used if you don’t want to merge the whole branch and you want some of the commits.

Implementation: 
Suppose a developer fails to recognize which branch he is currently on, and by mistake, he commits to another branch instead of committing that to the main branch. Now to fix it, he has to first run git show, then save the commit, then check out the main branch, apply patch there and commit with the same commit message. But all this can be done automatically by using just one command i.e. cherry-pick.

Q53. Explain what is MongoDB?
MongoDB, the most popular NoSQL database, is an open-source document-oriented database. The term ‘NoSQL’ means ‘non-relational’. It means that MongoDB isn’t based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data. This format of storage is called BSON ( similar to JSON format). 

A simple MongoDB document Structure: 

{
title: 'Geeksforgeeks',
by: 'Harshit Gupta',
url: 'https://www.geeksforgeeks.org',
type: 'NoSQL'
}

Q54. MongoDB vs MySQL

MongoDB MySQL
MongoDB is an open-source database developed by MongoDB, Inc. MongoDB stores data in JSON-like documents that can vary in structure. It is a popular NoSQL database. MySQL is a popular open-source relational database management system (RDBMS) that is developed, distributed and supported by Oracle Corporation.
In MongoDB, each individual records are stored as ‘documents’. In MySQL, each individual records are stored as ‘rows’ in a table.
Documents belonging to a particular class or group as
stored in a ‘collection’.
Example: collection of users.
A ‘table’ is used to store rows (records) of similar type.

Q55. What is Sharding in DBMS?
Sharding is a very important concept that helps the system to keep data in different resources according to the sharding process. The word “Shard” means “a small part of a whole“. Hence Sharding means dividing a larger part into smaller parts. In DBMS, Sharding is a type of DataBase partitioning in which a large database is divided or partitioned into smaller data and different nodes. These shards are not only smaller, but also faster and hence easily manageable.

Q56. What is use of capped collection in MongoDB?
Capped collections are fixed-size collections means when we create the collection, we must fix the maximum size of the collection(in bytes) and the maximum number of documents that it can store. After creation, if we try to add more than documents to their capacity, it overwrites the existing documents.

We create the capped collections using the createCollection() method in MongoDB. When we create a new capped collection, we must specify the maximum size of the collection in bytes, which will MongoDB pre-allocate for the collection. The size of the capped collection contains a small amount of space for the internal overhead and if the value of the size field is less than or equal to 4096, then the capacity of the collection is 4096 bytes.

Syntax:

db.createCollection(<name>, {capped: <boolean>, autoIndexId: <boolean>, size: <number>, max: <number>, storageEngine: <document>, validator: <document>, validationLevel: <string>, validationAction: <string>, indexOptionDefaults: <document>, viewOn: <string>, pipeline: <pipeline>, collation: <document>, writeConcern: <document>})

Q57. Strategies For Migrating From SQL to NoSQL Database
Migrating from a SQL database to a NoSQL database can be a complex process, but there are several strategies that can be used to make the transition smoother. Here are some common strategies for migrating from SQL to NoSQL:

  1. Analyze the current SQL schema and data model: Before starting the migration, it’s important to analyze the current SQL schema and data model to identify any potential issues that may arise during the migration. This analysis can help to identify any data relationships that may need to be modified, and any data that may need to be denormalized or split across multiple tables.
  2. Choose the right NoSQL database: There are several types of NoSQL databases, each with their own strengths and weaknesses. Choosing the right NoSQL database for the specific needs of the application is important to ensure that the data is stored efficiently and can be accessed easily.
  3. Identify data access patterns: NoSQL databases are optimized for different types of data access patterns than SQL databases. Identifying the data access patterns in the application is critical to selecting the right NoSQL database and designing an effective data model.

Q58. What are the CRUD operations of MongoDB?
As we know that we can use MongoDB for various things like building an application (including web and mobile), or analysis of data, or an administrator of a MongoDB database, in all these cases we need to interact with the MongoDB server to perform certain operations like entering new data into the application, updating data into the application, deleting data from the application, and reading the data of the application. MongoDB provides a set of some basic but most essential operations that will help you to easily interact with the MongoDB server and these operations are known as CRUD operations

Create Operations

The create or insert operations are used to insert or add new documents in the collection. If a collection does not exist, then it will create a new collection in the database. You can perform, create operations using the following methods provided by the MongoDB:

Method Description
db.collection.insertOne() It is used to insert a single document in the collection.
db.collection.insertMany() It is used to insert multiple documents in the collection.
db.createCollection() It is used to create an empty collection.

Q59. What is the Aggregation in MongoDB?
In MongoDB, aggregation operations process the data records/documents and return computed results. It collects values from various documents and groups them together and then performs different types of operations on that grouped data like sum, average, minimum, maximum, etc to return a computed result. It is similar to the aggregate function of SQL.

MongoDB provides three ways to perform aggregation

  • Aggregation pipeline
  • Map-reduce function
  • Single-purpose aggregation

Q60. What is limit() method in MongoDB ? 
 In MongoDB, the limit() method limits the number of records or documents that you want. It basically defines the max limit of records/documents that you want. Or in other words, this method uses on cursor to specify the maximum number of documents/ records the cursor will return. We can use this method after the find() method and find() will give you all the records or documents in the collection. You can also use some conditions inside the find to give you the result that you want.

  • In this method, we only pass numeric values.
  • This method is undefined for values which is less than -231 and greater than 231.
  • Passing 0 in this method(limit(0)) is equivalent to no limit.

Syntax:

cursor.limit()

or

db.collectionName.find(<query>).limit(<number>)

Q61. What are Pure Components?
In simple words, If the previous value of state or props and the new value of state or props is the same, the component will not re-render itself. Since Pure Components restricts the re-rendering when there is no use of re-rendering of the component. Pure Components are Class Components which extends React.PureComponent.

Q62. What is JSX?
JSX is basically a syntax extension of JavaScript. It helps us to write HTML in JavaScript and forms the basis of React Development. Using JSX is not compulsory but it is highly recommended for programming in React as it makes the development process easier as the code becomes easy to write and read.

Let us see a sample JSX code:

const ele = <h1>This is sample JSX</h1>;

Q63. What is state in React?
The state in React is an instance of React Component Class that can be defined as an object of a set of observable properties that control the behavior of the component.In other words, the State of a component is an object that holds some information that may change over the lifetime of the component.

Q64. What are props in React?
React allows us to pass information to a Component using something called props (which stands for properties). Props are objects which can be used inside a component.

Q65. Why we use synthetic events in ReactJS ?
In ReactJS, there are events by which user uses to interact with an application UI. React listens to events at the document level, after receiving events from the browser, React wraps these events with a wrapper that has a similar interface as the local browser event, which helps us to use methods like preventDefault().

Benefits of using synthetic events:

  • Cross browsers applications are easy to implement.
  • Synthetic events are that ReactJS reuses these events objects, by pooling them, which increase the performance.

Q65. What is the use of refs?
Refs are a function provided by React to access the DOM element and the React element that you might have created on your own. They are used in cases where we want to change the value of a child component, without making use of props and all. They have wide functionality as we can use callbacks with them. 

Creating refs in React

Refs can be created using React.createRef() function and attached it with the React element via the ref attribute. When a component is constructed the Refs are commonly assigned to an instance property so that they can be referenced in the component. 

class MyComponent extends React.Component {
constructor(props) {
super(props);
this.myCallRef = React.createRef();
}
render() {
return <div ref={this.myCallRef} />;
}
}

Q66. What is children prop?
The important thing to note here is that children are a special prop that is used to pass the data from the parent component to the children component but this data must be enclosed within the parent’s opening and closing tag.

<SomeComponent title={state.Title} description={state.Description} />

Q67. Why is NodeJS Single threaded?
Applications built on the top of node.js use Single Threaded Event Loop Model architecture to handle multiple concurrent clients like JSP, Spring MVC, ASP.NET, HTML, Ajax, jQuery, etc. are other web technologies that can be used rather than node.js but these listed technologies follow “Multi-Threaded Request-Response” architecture to handle multiple concurrent clients.

Single thread: Node JS Platform doesn’t follow the Multi-Threaded Request/Response Stateless Model. It follows the Single-Threaded with Event Loop Model. Node JS Processing model mainly inspired by JavaScript Event-based model with JavaScript callback mechanism. Because of which Node.js can handle more concurrent client requests with ease.

Q67. Explain the usage of a buffer class in Nodejs?
The Buffer class in Node.js is used to perform operations on raw binary data. Generally, Buffer refers to the particular memory location in memory. Buffer and array have some similarities, but the difference is array can be any type, and it can be resizable. Buffers only deal with binary data, and it can not be resizable. Each integer in a buffer represents a byte. console.log() function is used to print the Buffer instance.

Methods to perform the operations on Buffer:

Method Description
Buffer.alloc(size) It creates a buffer and allocates size to it.
Buffer.from(initialization) It initializes the buffer with given data.
Buffer.write(data) It writes the data on the buffer.
toString() It read data from the buffer and returned it.
Buffer.isBuffer(object) It checks whether the object is a buffer or not.

Q68. What is the role of async_hooks module in nodejs?
Async_hooks module is used because it provides an API to register callbacks tracking the lifetime of asynchronous resources created inside a Node.js application.

Features:

  • You can capture any asynchronous activity in a Node.js process.
  • Minimal performance overhead.
  • Powerful and flexible API.

Q69. Explain REPL In NodeJs?
 Node.js is an open source server-side Javascript run-time environment built on Chrome’s JavaScript Engine(V8). Node.js is used for building fast and scalable applications and is an event driven, non-blocking I/O model.

REPL (READ, EVAL, PRINT, LOOP) is a computer environment similar to Shell (Unix/Linux) and command prompt. Node comes with the REPL environment when it is installed. System interacts with the user through outputs of commands/expressions used. It is useful in writing and debugging the codes. The work of REPL can be understood from its full form:

Read : It reads the inputs from users and parses it into JavaScript data structure. It is then stored to memory.
Eval : The parsed JavaScript data structure is evaluated for the results.
Print : The result is printed after the evaluation.
Loop : Loops the input command. To come out of NODE REPL, press ctrl+c twice

Q70. What is a V8 Engine in NodeJS?
V8 is a C++-based open-source JavaScript engine developed by Google. It was originally designed for Google Chrome and Chromium-based browsers (such as Brave) in 2008, but it was later utilized to create Node.js for server-side coding. In reality, JSON-based No-SQL databases like Couchbase and the widely used MongoDB use the V8 engine. V8 also powers Electron, a prominent desktop application framework, and Demo, the latest server-side runtime environment.

Q71. What Is EventEmitter In NodeJs?
Node.js uses events module to create and handle custom events. The EventEmitter class can be used to create and handle custom events module.
The syntax to Import the events module are given below:

Syntax:

const EventEmitter = require('events');

All EventEmitters emit the event newListener when new listeners are added and removeListener when existing listeners are removed. 

Q72. What is meant by Collections in Java?
Any group of individual objects which are represented as a single unit is known as a collection of objects. In Java, a separate framework named the “Collection Framework” has been defined in JDK 1.2 which holds all the collection classes and interface in it.

In Java, Collection interface (java.util.Collection) and Map interface (java.util.Map) are the two main “root” interfaces of Java collection classes.

Q73. What is the life-cycle of a servlet?
The entire life cycle of a Servlet is managed by the Servlet container which uses the javax.servlet.Servlet interface to understand the Servlet object and manage it. So, before creating a Servlet object, let’s first understand the life cycle of the Servlet object which is actually understanding how the Servlet container manages the Servlet object.

Q74. What is an iterator?
Iterators in Java are used in the Collection framework to retrieve elements one by one. It is a universal iterator as we can apply it to any Collection object. By using Iterator, we can perform both read and remove operations

Q75. What is Entity Bean?
Enterprise Java Beans (EJB) is one of the several Java APIs for standard manufacture of enterprise software. EJB is a server-side software element that summarizes business logic of an application. Enterprise Java Beans web repository yields a runtime domain for web related software elements including computer reliability, Java Servlet Lifecycle (JSL) management, transaction procedure and other web services. The EJB enumeration is a subset of the Java EE enumeration.

Q76. java.util.concurrent Package
Java Concurrency package covers concurrency, multithreading, and parallelism on the Java platform. Concurrency is the ability to run several or multi programs or applications in parallel. The backbone of Java concurrency is threads (a lightweight process, which has its own files and stacks and can access the shared data from other threads in the same process). The throughput and the interactivity of the program can be improved by performing time-consuming tasks asynchronously or in parallel.

Q77. What is the difference between put and patch?

PUT

                                          PATCH      
PUT is a method of modifying resource where the client sends data that updates the entire resource .                                      PATCH is a method of modifying resources where the client sends partial data that is to be updated without modifying the entire data.
In a PUT request, the enclosed entity is considered to be a modified version of the resource stored on the origin server, and the client is requesting that the stored version be replaced With PATCH, however, the enclosed entity contains a set of instructions describing how a resource currently residing on the origin server should be modified to produce a new version.
HTTP PUT is said to be idempotent, So if you send retry a request multiple times, that should be equivalent to a single request modification HTTP PATCH is considered idempotent. When a PATCH request is sent multiple times, it will have the same effect as sending it once

Q78. What is docstring in Python?
Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, and methods. It’s specified in source code that is used, like a comment, to document a specific segment of code.

Q79. Difference between List and Array in Python

List

Array

Can consist of elements belonging to different data types

Only consists of elements belonging to the same data type

No need to explicitly import a module for the declaration

Need to explicitly import the array module for declaration

Cannot directly handle arithmetic operations

Can directly handle arithmetic operations

Preferred for a shorter sequence of data items

Preferred for a longer sequence of data items

Greater flexibility allows easy modification (addition, deletion) of data

Less flexibility since addition, and deletion has to be done element-wise

Q80. Difference Between Pickling and Unpickling in Python

Pickling Unpickling

Serialization process that converts a Python object into a binary representation.

Deserialization process that converts a binary representation back into a Python object.

Allows objects to be stored in a file or transmitted over a network.

Retrieves objects from a stored file or received data.

Uses the pickle.dump() function to write objects to a file or a stream.

Uses the pickle.load() function to read objects from a file or a stream.

Objects are converted into a binary format that is not human-readable.

The binary format is converted back into Python objects, which can be used in Python code.

Supports serialization of complex objects, including custom classes, functions, and data structures.

Supports deserialization of complex objects, including custom classes, functions, and data structures.

Q81. Python program to split and join a string
Python program to Split a string based on a delimiter and join the string using another delimiter. Splitting a string can be quite useful sometimes, especially when you need only certain parts of strings. A simple yet effective example is splitting the First-name and Last-name of a person. Another application is CSV(Comma Separated Files). We use split to get data from CSV and join to write data to CSV. In Python, we can use the function split() to split a string and join() to join a string. For a detailed articles on split() and join() functions, refer these : split() in Python and join() in Python

Examples:

Split the string into list of strings
Input : Geeks for Geeks
Output : ['Geeks', 'for', 'Geeks']
Join the list of strings into a string based on delimiter ('-')
Input : ['Geeks', 'for', 'Geeks']
Output : Geeks-for-Geeks

Python




# Python program to split a string and
# join it using different delimiter
  
def split_string(string):
  
# Split the string based on space delimiter
list_string = string.split(' ')
  
return list_string
  
def join_string(list_string):
  
# Join the string based on '-' delimiter
string = '-'.join(list_string)
  
return string
  
# Driver Function
if __name__ == '__main__':
string = 'Geeks for Geeks'
  
# Splitting a string
list_string = split_string(string)
print(list_string)
  
# Join list of strings into one
new_string = join_string(list_string)
print(new_string)


Output

['Geeks', 'for', 'Geeks']
Geeks-for-Geeks



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads