Best Interview Questions for Backend Development

Node js Interview Questiojs

What is Node js?

  • Open Source, cross -platfrom, Javascript runtime and librray for running applications outside client’s server.
    It is used for creating server-side applications
    Node.js is perfact for data intensive applications as it uses an a synchronous , event -driven application.

Node.js basesd on V* engine, It is virtual machine that utilizes, Javascript as its scripting language achives and high output non-blocking I?o and single threaded event loop.

Where Can We use Node js?

Web Applications
Distributed Systems
Network Applications

The Term I?o is used to describe any program, operation or device that transferes data or from a medium and to or another form.

Frontend vs Backend

(1) Frontend refers to the client side of an application and backened refers to the server side of an application

(2) It is the part of web application that users can see and interact with whikle Backend constitutues that happenes behind teh scenes.

(3) It is typically includes evrything that attributes to the visual aspect of a web application, It geenrally includes a web server that commincates with database server requests.

(4) HTML, CSS, jAVASCRIPT, Anugular Js and React Js are some kind of the essentials of the frontend development. Java, PHP, Python and Node.js are some of the backend development Technologies.

What is NPM?
Node package Manager provides two main functions.
It provides online repositories for node.js packages which are searchable on serach nodejs.org

It also provides command line utility tool to install Node.js packages, does version management and dependency of Node.js packages.

Modules are like Javascript libraries that can be used in a Node.js application to include a set of functions.

To include a module in a node.js application, use require() function with the parenthesis containing the name of the module.

Node js has many modules to ptovide a basic functionality neede for web applications.

Some of them are mentioned in table.

Core Modules Description
http – Includes classes, methods, events to create Node.js http server.

Util – Includes utility functions useful for developers
fs – Includes events,classes, and methods to deal with file I/O Operations.
url – Includes methods for URL parsing.
query string – includes method to work with the query string.
Stream – Includes methods to handle streaming data
Xlib – Include methods to compress or decmpress files.

Why is Node js is being preferred over other backend technologies like Java and PHP?

Node Js is really fast


Node package manager has over 50,000 bundles at the developer’s disposal.
Perfect for data-intensive, real-time web applications as Node.js Server waits for an API to return the Data.
Better Synchronization of code between server and clients due to the same code base.
Easy for web developers to start using Node.js in their projects as It is as Javascript Library.

Angular vs Nodejs

Angular is a frontend developement Framework. It is a server-side environment.
It is written in Typescript. While Node js is Written in C, C++ language.

Angular used for building single page clienct side based web applicartions While Node js used for building fast and scalable server -side rendering network applications.

Angular Js Splits a web application into MVC components While Node js Generates the database Queries.

MongoDB – MongoDB is the most popular database used with Node.js. It is NoSQL, cross-platform, document-oriented database, high performance, high availability and easy scalability.

Express Js – Express is a flexible Node.js Web Application framework which provides a wide set of feature to develop both web and Mobile applications.

Mongoose – Mongoose is a also a Node js web application framework to database to do a simpler task.

What is the command used to import external Libraries?

Command require is used for importing external libraries, for example, “var http = require(“http”). This will load the http library and the single exported object through the http variables.

Intermediateries Node.js Questions

What Does Event Driven a Programming language?

Event Driven Programming approach excessedingly uses events to trigger various functions. An event can be anything, such as the pressing key or clicking of a mouse button.

A call-back function alerady registered with the event is executed.

What is Event Emitter in Node js?

Event Emitter is a class which holds all the objects that can emit events.
Whenever an object from the EventEmitter class throws an event. All the attached functions are called upoon synchronously.

const EventEmitter=require(“events”);
class MyEmitter extends EventEmitter()
const MyEmitter = NewEmitter()
MyEmittoron(“event,() => {
console.log(“Event is occured”);
));
myEmitteremit(“event”);

What are the API functions in Node.js?

Two types of API funtions in Node.js

  • Asynchronous, Non-Blocking functions
  • Synchronous, Blocking functions

What is package json Files?

The package Json file is the heart of a Node.js system.
This file holds the metadeta about a particular project.
Package.json is present in the root directory of any Node Application or Module.

{
“name” : “node-npm”,
“version”: “1.0.0”
“decription” : ” A demo application”,
“main” : “index.js”
“scripts”: {
test : “echo \” Error no test specified\ “‘&& exit!”
}
Author : “Taha”
“Licences: ” ISC”
}

This is how a package.json file looks like immediately after creating a Node.js project using the component npm init.
You can edit these parameters at the time of creation of Node.js project.

Var url = require(“url”);
var adres = “http:’//localhost 8080/ default htm? year = 2020& month = march;
var que = urlParse(addres, true);
console.log(que.host)
console.log(que.pathname)
console.log(que.search)
var quedata = que.query
console.log(quedata.month)

What is Express Js package?

Express js is a flexible Node.js web application framework which provides a wide set of features to develop both web and Mobile
applications/

The request object represents the HTTP request and has properties for the request query string, parameters body HTTP headers and so on.
The response objects that an express app sends when it gets an HTTP request.

Streams are object that let you read data write data continuously.

There are four types of the steams :
(1) readable
(2) Writable
(3) Duplex
(4) Transform

install dependency

npm install express

update Dependecy

npm update

uninstall dependency :

npm uninstall express

How can we create a simpkle server in Node js that return a hello world?

We can create a simple server using Node.js using this code.

var http : require(“http”)
http.CreateServer (function(req,res) {
res.writeHead(200,{“Content- Type “: “text/Plain’}0;
res.send(“Hello world\n”)

All the API’sof Node js a libraryt are asynchronous which means Non- Blocking.

Node js is based server never waits for an API to return data, It moves to next API after calling it. and a Notifcation mechanism of Events of Node js responds to the server for the previous API call.

This is the async server never waits for an API to return data, instead it moves to the next API after calling it and a notification mechanism of Events of Node js responds to the server for the previous API call.

We can create a simple Node.js based serer never waits for an API to return data, instead it moves to the next API after calling it. and a notification mechanism of Events of Node.js responds to the server for ther previous API call.

This Async function code that asks the jaavscript engine running the code wait for request.get() function to complete before moving on the next line to execute it.

Async funcction fun1 (req,res) {
let response = await request.get(“http://localhost:3000),
if(response.err) (console.log(“error”),)
else (console.log(“fetched response”);
}

Q(27) What is the purpose of the Module Exports?

A module in node js used to encapsulate all the related codes into a single unit of code which can be interprted bu shifting all related functions into a single file.

You can export a module exports so that it can be implemented in another file using require meantime.

(28) What is a Callback Function in Node.js?

A callback is a function called at the completion of given task and allow other code to be run in a meantime.

Advanced Node Js Question?

(1) What is REPL in Node.js?

REPL, stands for read, Eval , Print and Loops and it represents a computer enviroment like window console or unix/ linux shell where a command is entered, and a system responds with output.

REPL performs the following desired tasks
Read- Read user’s input, parses the input into Javascript data -structure and stores in Memory.
Eval – Takes and evaluate the data atructure.
Print – Print the result
Loop – Loops the above command untill user presses the Ctril + C twice

(2) what is Control Flow Function?

Control Flow function is a piece of code which runs in between several several asynchronous function?

The Control Flow does the following jobs.

Control the order execution.
Collect data
Limit concurrency
Call the next step in a program.

(3) What is the difference between fork() and Spawn () Methods in Node.js?

Fork() is a particular case of Spawn() that generates intergers but correspondes to a raw memory to a raw memeory allocation outside function. Sprawn() function launches a new process with the available set of commands.

in Fork, Multiple Workers run on a single node code based multiple tasks. This method doesn’t generate a new VB instance, and only a single copy of the node module is active on processor.

(4) What is the Usage of Buffer Class In node js?

Buffer Class stores (raw data similar to an array of integeres, but corresponds to a raw mempry allopcation outside the V* heap.

Buffer class is used because pure javascript is not compatible with binary data.

(5) What is Piping in Node js?

Piping is a mechanism to connect output of one stream to another stream.
It is normally used to get data from one stream and to pass output for that stream to another stream.

(6) What are the some of the flags used in read/write operations in files?

r- Open File for reading. An exception if the file does not exist.
r+ – Open file fopr reading and writing. An exception occurs if the file does not exist.
w – Open file for writing. The file created ( if it does not exist or truncated)
W+ – Open file for reading and writing. The file is created(if it does not exist) or trucated (if it is exist)
a- – Open file for appending. The file is a createrd it does noot exist.
a+ – Open file for reading and appending. The file is created if it does not exist.

(7) How will You Open a file using Node.js?

This is the syntax of opening a file in Node.js

fs.open(path,flags[. mode], callback)

(8) What is Callback Hell?

Callback Hell ,also known as the Pyramid of DoM, is caused by intensively nested, unreadable and unmanagable callbacks, which in turn makes the code harder to read and debug.
It is caused by improper implementation of the asynchronous logic.

(9) What is the reactor Pattern in Node js?

Reactor – Reactor pattern is a concept of non- blocking I/O operartions.
This pattern provides a handler that is associated with each I/O operation and as an I/O request is geenrated, It is then submitted to demultiplexer.

(10)What is Test Pyramid in Node js?

A test Pyramid is a figure which explains the proportion of Unit tests,integrations and end-to-end tests that are required for the proper development of a project.

The componentb of a test pyramid are given below :
Unit test – The test the individual units of code in the isolation.

Integration Tests : The test the individual units are of the integaration amoug dissimilar units

End – to -End (E2E Tests) : They test the whole system, from the user interface to the data store and back.

(11) Describe the Exit Code of Node js.

Exit Code are a set of specific codes which are used in finishing a specific process. Given below are some of the exit code used in Node js.

Uncaught fatal exception
Unused
Fetal Error
Internal Exception Handler Run-Time Failer
Internal javascript Evaluation failure

(12) Explain the concept of Middleware in Node js?

Middleware is a function that receives the Request and Response objects, Most performed tasks by the middleware are :

  • Executes aby types of Code
  • Update or modify the request and the response Objects
  • Finish the Request- response cycle.
  • Invoke the next middleware in the stack.

(13) What are the Types of HTTP requests?
Http defines a set of requests methods to perform the desired actions.

GET – This request used to retrieve the data.
POST – Generally, used for causing a change in state or reactions on the server.
HEAD – This HEAD method in similar to the GET method but asks for the response without the response body.
DELETE – It is used to delete the predetermined resources

(14) How Would You connect a MongoDb database to Node.js?

To create a database in MongoDB

  • Start by creating a mongoClient object
  • Then specify the a Connection URL with the correctb ip address and the name of the database you want to create.

var MonoClient = require(“mongodb”). MongoClientt
var url = “mongodb://localhost 27017/mydb”

MongoDbClient connect (url, function(err,db) {
if (err) throw err;
console.log(“Database Created”)
db.close()
]);

(15) What is the use of NODE_ENV?

To set an environment.

NODE_ENV is an environemntal variable that stands for node environment in express server .
It’s how we set and detect which environment we are in
export NODE_ENV = production

(16) List down various timing features of Node.js?

Timers Module is provided by Node.js which contains various functions for executing the code after a specified period of time. Various functions that are provided by this module.

Set Timeout/ Clear TimeOut – Used to schedule code execution after a designated Amount of milliseconds.

Setinterval/ ClearInterval – used to execute a block od code multiple times.

setimmediate/ClearImmediate – Used to execute code at the end of the current event loop cycle.

SQL Interview Questions

(1) Find the lowest salary from database

use sql_intro;
select * from employees;
select dept, min(salary) as lowest_salary from employees group by dept.

(2) Which query will help you to fetch unique values from a column in a table?

Answer select DISTINCT column_name from table_name

(3) Write the SQL query to fetch unique departents from the Employee_table?

select DISTINCT dept from employees;

(4) Write an SQL query to fetch the uni1ue values of departments and print their length

select distinct dept, length(dept) as length_dept from employees.

(5) What is the use of DATEDIFF function in MYSQL?

select datediff(‘2021-04-10’, ‘2021-03-30’) as total_days

select datediff(now(),”2021-04-15″)

(6) Write an SQL query to display the department that have more than 2 employees.

Select dept, count(emp_id)from employee group by dept having count(emp_id) > 2;

(7) Display the details of Employee for all the departments except Marketing

Answer : Select * from employees where dept <> or != “Marketing”

(8) Write an SQL Query to print the details of the employee who have joined in before April 2010 and after May 2005;

Select * from employees where doj > “2005-05-31” and doj < “2010-04-31”;

(9) Find the employee with the 3rd Highest Salary from the table.

select * from (select * from employees order by salary limit 3);

(10) Find Alternate records in table

select * from employees where emp_id % 2 = 1;
select * from employees where emp_id % 2 = 0;

(11) Write the Dupicateb Query to duplicate raws in table

select e_id, name , age, count(*) from as dup_count from dup_employees group by e_id, name , age
having count(e_id) >1

(12) Display the employee Having 2 A’s in their name.

select * from employees.

select length(replace(upper(emp_name),’A’,””)) from employees;

(13) Given a string, how will you extract four characters starting from the second position?

Select substr(“Micheal Ballaback”,2 ,4)

(14) How does self Join works?
The self join joins a tables to itself. The table must contain a column (x) that acts as the primary key and different coklumn (y) that stores vakues that can be matched up with the values in column x.

What is Maven?

Open Source tool developed by Apache Gropu to Build, Publish and deploy several Project at once.

Written in java and it is used to build projects written in C#, Scala, Ruby.

Developed and Managed by Java-Based Projects. Simplifies such as building, documentation,relasing in Project Management

(2) What Does Maven Takes Care of?

In the process, It takes care of the following

  • Builds
  • Dependencies
  • Distribution
  • Releases
  • Mailing list

(3) What is Primary Differnce Between ANT and Maven?

ANT has no formal conventions, so information is to be provided in .xml file. Maven has conventions so information not be provided in pom.xml file.

ANT is procedural. Maven is declarative
ANT has no life cycle, Maven has a lifecycle
The scripts are not reusbale, Maven is mainly used as project management tool
The scripts are not reusable and Maven is mainly used as a project management tool.
ANT is specially a build tool. Maven Plugins are reusbale.

(4)What is POM?

Project Object Model(POM) refers to the XML files with all information regarding project and configuration details.

It has the description of the project, infromation regarding the versioning and configuration management of the project

The XML files with all the information regarding the versioning and configuration management of the project.When we tend to execute a task. Maven schedules the POM for the current directory.

(5)POM contains following configurations

Dependencies
Developers and Contributors
Pugins
Plugin Configurations
Version

Minimum requirements
Dependencies
Developers and Contributors
groupId- project’s group id
artifcatid – Artifact (project) id
Version

(6) What is the meastthe buisd tools?

Generating Source code
Generating Documentation from the source code
Compiling source code
packaging of the compiled codes into JAR files.

(7) How to install MAVEN on windows?

Download Maven and then extract it

In the environment varuiables ass JAVA_HOME, MAVEN_HOME

Then add enviroment path in Maven variable

Lastly verify Maven installation by checking its version.

MVN install is used to isntall JAR in the local depository

To installl the JAR manually into the local Maven repository, the following plugin used

mvn installation- file- Dfile =

How do you know version of Maven Being used?

Mvn – Version is used to check the version present in the system.

There are three build life cycles

(1) clean – Clean Up all the directories
(2) Default – The default lifecycle handles the project deployment
(3) site – The site lifecycle refers to the creation of the Project’s documentation.

(8) What is Maven Repository?

Maven repositorioes refers to the directories of the packaged JAR files that contain metadeta. The metadeta refers to the POM files relevant to each project, The metadeta is what allows maven to download dependencies

  1. Local Repositories
  2. Remote Repositories
  3. Central Repositories

Local Repository

Local Repository refers to the machine of the developer where all the project material is saved.

The local repository contains all the dependency jars.

Local repository present on locally avaiable where all the project material is saved.

The remote depositories refers to the depository used on server that is used when maven needs to download dependencies.

Central Depositories refers to the Maven community that comes into action when there is need for dependencies and those dependencies cannot be found in local depoistory.

How Does Maven Architecture Work?

Maven Architecture works in the three steps.
(1) Read pom.xml file
(2) Download dependencies defined in POM.xml into local repository from the central repository.
(3) Create and Generate a report according to the requirements life-cycles, phases, goals and plugins.

What is Maven Build Life Cycle?

Maven Lifecycle is a collection of steps that are to be followed to build a project.

Default – handles project deployment
clean – hanldes Project cleaning
Site – handles the creation of project site’s documentation.

What are the diffeernt kind of phases in the Maven Build Lifecycle?

Compile
test-compile
test
Package
Integration-test
verfiy
install
Deploy

Which command is used to build Maven site?

  • mvn site command is used to build Maven site.
    The resulting site by default target/ site/..

What is Maven Artifact?

Maven Artifact to a file, usually JAS that gets deployed to a Maven Repository.

Maven Artifat refers to file usua.ly a JAR that gets deployed to the Maven repository
The tool creates one or more articles, such as compiled JAR and Source JAR.

Every artifact has its groupID, an artifact IDM and a version string, These Togather identify the artifact.

The phases of a clean lifecycle includes

Pre-clean
clean
Post-clean

What are the phases in clean Life cycle?

Tjhe phases of clean Life cycle Includes
Pres-site
Site
Post-site
Site-Deploy

Maven Plugins are the important featuires of Maven used to reuse the common build logic across several projects.

The Plugins are needed to carry out tasks like compiling code , testing them, creating jar files and documentation odf the project.

Why are Maven Plugins Used?

Generate a jar File
generate a War File
Compile Code files
Unit testing of code
Create A project docuementation

Types of Plugins available

Build Plugins
Reporting Plugins

(1) Explain Master Slave Architecture of Jenkins
(2) What is Jenkinsfile?
(3) Which of the following commands runs Jenkins from the command file?
(4) What are the key aspects of the Jenkins Pipleline?

Scripted Pipeline – It is based on Groovey Script as their Domain Specific Language . One or more nodes blocks does the core work done throughout the pipeline

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *