Full-stack developers are skilled programmers who can work with both the front-end and back end of a
website and applications, They are responsible for developing and designing front/ back ends web
architecture, server-side applications, design databases, server-side applications, and much more.
STACK IN DS
C PROGRAM TO IMPLEMENT
STACK
It is the reason why tech glants hiring full-stack developers and conducting interviews for the same, You can
increase your chance to get hire by companies if you have well prepared for the full stack developer
interview. In this section, we have collected some full-stack developer interview questions that can
help you to crack the interview to get your dream job,
In the past few years, the job profile of a full-stack developer has increased because they are able to work
with different technologies and languages. Besides this, full-stack developers are also experts to solve the
anomalies raised across the different phases of the application or web development.
Angular
React
JavaScript
css
HTML
iRelational Database
@@ Front End
End User
NL Full Stack Java Developer
Java Full Stack Developer
1) What should a full-stack developer know?
Full-stack developer must introduce with the following
© Programming Languages: A full-stack developer must have proficient in more than one
programming language like Java, Python, Ruby, C++, etc. One must familiar with different ways to
structure design, implement and test the project based on the programming language
© Front End: One must familiar with the front-end technologies like HTMLS, CS$3, Angular, etc. The
understanding of third-party libraries like jQuery, Ajax, SASS, adds more advantages,
© Frameworks: Proficiency in words that are accompanied by development frameworks like Spring,
Spring Boot, MyBatis, Djengo, PHP, Hibernate, js, yin, and more.
© Databases:One must be familiar with at least one database. If you are familiar with MySQL, Oracle,
and MongoDB itis sufficient.
© Design Ability:The knowledge of prototype design like Lil and LIX design is also necessary.
2) What are MVC and MVP and how MVC is different from MVP?
MVC and MVP both are architectural patterns that are used to develop applications,
MYC
MVC stands for Medel View Controller. It is an architectural pattern that is used to develop Java
Enterprise Applications, It splits an application into three logical components i.e. Model, View, and
Controller. It separates the business-specific logic (Model component) from the presentation layer (View
component) from each other.
The model components contain data and logic related to it The View component is responsible for
displaying model objects inside the user interface, The Controller receives the input and calls model objects
based on handler mapping, It also passes model objects to views in order to display output inside the view
layer
Model View Controller
Controller
| %
: Up
$e
: ° NS) Model
@ 3] Forwards
eo «
| e
: é
' Dre
t oe
View
MvP
MVP stands for Model View Presenter. |t is derived frorn the MVC architectural pattern. It adds an extra
layer (known as indirection) to the architectural pattern that splits the View and Controller into View and
Presenter. The role of Controller is replaced with a Presenter. It exists at the same level as View in MVC. It
contains Ul business logic for the View. The invocations received from the View directly sends to the
Presenter. It maintains the action (events) between View and Model. The Presenter does not directly
communicate with the View. It communicates through an interface.
Model View Presenter
Model
View
User Presenter
@ 1] Interacts
6] Displays
2] Notifies 3] Updates
5] Updates 4] Gets Data
The major difference between MVC and MVP architectural pattern is that in MVC architectural pattern
Controller does not pass the data from the Model to the View. It only notifies the View to get the data from
the Model itself
While in M¥P architectural pattern the View and Model layers are connected with each other. The presenter
itself receives the deta from the Model and sends it to the View to show.
ox
Download Flutter SDK
Oo
& Flutter
e Control every pixel to create custorrized & adaptive
eee designs that look great on any screen.
= &
Flutter Learn More >
Another difference is that MVC is often used in web-frameworks while MVP is used in app development
MVC
3) What is pair programming?
Pair programming (a fundamental aspect of programming) is an agile software development technique in
which two developer works together on the same machine (system). The developer who writes the code is
called the driver and the developer who reviews (checks code, proofread, and spell checks) the code is
called the navigater. The programming technique Is more efficient and coding mistakes reduced to the
minimurn. The disadvantage of pair programming is that it increases the cost.
4) What is CORS in MVC and how it works?
CORS stands for Cross-Origin Resource Sharing. It is a W3C standard and HITP-header-based
mechanism. It permits a server to indicate any other arigins (like domain, port, etc) instead of the requested
one. In other words, it enables one website to access the resources of another website using JavaScript
It supports secure cross-origin requests and transfers data between servers and browsers, Advanced
browsers use CORS in APIs, Itis flexible and safe in comparison to JSONP (ISON with Padding). It provides
better web service integration,
Request
Inttp://abe.com/x
http://abe.com/y
Same Origin request
Request
http://abe.com/x —s ‘http://xye.com/e
Cross Origin request
While using the MVC to enable CORS, the same CORS service can be used but we cannot use the same
CORS middleware. We can use a particular CORS for a particular action, for a particular controller, and
globally for all controllers.
Apprecflight check (or request) is sent by the browser to the server (hosting the cross-origin resource) which
ensures that the server will permit the actual request or not, For example, invoking the URL
https://example.com through https://demo.com
Server configured with
i CORS policy
> https://api.github.com/users/
Server
https://github.com <
Client Header
Access-Control-Allow-Origin : https://github.com
Working of CORS
5) How to enhance a website's scalability and efficiency?
We can use the following ways to optimize the scalability and efficiency of a website
© Reducing DNS lookup
Avoiding URL redirects
Avoiding duplicate codes
Avoiding unnecessary images
Leveraging browser caching
Deferring parsing of JaveScript
Avoiding inline lavaScript and CSS
Using sreset for responsive images
Placing all assets on a cookie-free domain, preferably using a CDN
6) What are the differences between Get and Post requests?
S.N. Basis of Get Post
Comparison
1 Purpose The Get request is designed for The Post request is designed for
getting date from the server. sending the data to the server.
2 Post Mechanism The requestis sent via URL. The request is sent via an HTTP
request body.
3 Parameter The request parameters are The request parameters are
Passing transmitted as a query string transmitted with the body of the
appended to the request. request,
4 Default It is the default method hence it We need to specify manually.
implements automatically.
5 Capacity We can send limited data with the Get We can send a large amount of
request, data with the Post request,
6 Data Type Italways submits data as text, We can send any type of data
7 Security The use of Get is safe because it is The use of Post unsafe because it
idempotent. is non-idempotent,
8 of The data is visible to the user as it The data is net visible to the user
puts the data in the URL. as it puts the data in the message
body.
9 Bookmark and The Get request can be bookmarked The post request cannot be
Caching and caching, bookmarked and caching
10 Efficiency Itis more efficient than post. Itis less efficient
11 Example Search is the best example of Get Login is the best example af a Post
request.
request.
7) What is referential transparency in functional programming?
A program may have the property of referential transparency if any two expressions in the program that
have the same value can be substituted for one anather anywhere in the program without changing the
result of the program. It is used in functional programming, For example, consider the following code
snippet
count! = (fun) +y) * une) -2);
temp = fun(a);
count2 = temp + y* temp - 2;
The variables count and count2 will be equal if the value of fun(®) is not reflected, If the variable countt is
not equal to the variable count2, the referential transparency is violated
8) What is RESTful API?
The term REST stands for Representational State Transfer. It is an architectural style that is used to create
Web Services. It uses HTTP requests to access and use the data. We can create, update, read, and delete data.
An API (Application Program Interface) for a website is the code that allows two software programs to
communicate with each other. It allows us to write requesting services from an operating system or other
application.
9) What do you mean by promise, also explain its states?
A promise is an object that can be returned synchronously from an asynchronous function. It may be in the
following three states:
©. Fulfilled: If a promise called the onFulfilledg method, a promise will be in fulfilled state,
© Rejected: If a promise called the onRejceted) method, a promise will be in rejected state
© Pending: If apromise is not yet fulfilled or rejected, a promise will be in pending state.
A promise will be settled if and only if itis not pending
10) How to reduce the load time of a web application?
There are the following ways to optimize the load time of a web application:
© Optimize image size and format
© Compress and optimize the content
© Avoid redirects
Cache the web page
Minimize the HTTP requests
Optimize dependencies
Put stylesheet reference at the top
Place script reference at the bottom
Put JavaScript and CSS externally
11) What is a continuous integration and continuous delivery (CI/CD)?
CI/ED is a best practice to develop applications in which code changes more frequently and rapidly.
Sometimes, itis also known as CI\CD pipeline. Itis widely used in DevOps and also an agile methodology.
Continuous integration is a coding philosophy or deployment practice in which developers integrate their
code in a shared repository several times a day. Because modem application requires developing code in
different platforms. The goal of continuous integration Is to establish an automated mechanism that builds,
test, and package the application
Continuous delivery starts where Cl ends. It automatically delivers the application to the selected
infrastructure. CD ensures the automated delivery of code if any changes are made in the code.
12) Which architectural designs are mostly used to design applications?
In software design, we use the following architectural design patterns:
© Model View Controller
© Master-Slave Pattern
Layered Pattern
Model View Presenter
Monolithic Architecture
Event-Driven Architecture Pattern
13) What is long polling?
Long polling is an effective method for creating a stable server connection without using the WebSocket or
Server-Side Events protocols. It operates at the top of the conventional client-server model. Note that
Nodejjsis using the same technique as the next development model
In this method, the client sends the request and the server responds until the connexon is open as it
contains new and unique information. As soon as the server responds, a request to the client can be
submitted. When the datais available, the server will return a query. It functions when the client application
stops and the server ends requests,
14) Explain semantic HTML with an example and why we should use it?
In web design, the idea of using HTML elements to indicate what they actually are, Itis known as semantic
HTML or semantic markup.
Semantic HTML is HTML that represents meaning to the web page rather than just presentation. For
example, tag
indicates that a paragraph is enclosed in it. tis both semantic and presentational because
the user know what paragraph are and the browser also know how to display them. On the other hand, tags
such as and are not semantic. Thay only represent how text should look. These tags do net provide
any additional meaning to the markup.
Example of semantic HTML tags are header tags to , , , , ,
, , etc, There are some other semantic HTML tags that are used to bulld a standards-
compliant website.
We should use the semantic HTML for the following reasons:
© It provides additional information about the document in which it is used. It also aids in
communication.
© Semantic tags make it clear to the browser what the meaning of a page and its contents.
© It provides information about the contents of those tags that goes beyond just how they look on a
page
© Itgives us many more hooks for styling the content of the page
©. The clarity of semantic tag is also communicated with search engines that ensure the right pages are
delivered for the right queries,
15) How null is different from undefined in JavaScript?
Null: Null means a variable is assigned with a null value, If we use it with typeof operator it gives result as
an abject, We should never assign a variable to null because the programmer uses it to represent a variable
that has no value, Note that JavaScript will never automatically assign the value to null
Undefined: Undefined means the variable is declared but not assigned any value to it It may be a variable
itself does not exist. If we use itwith typeof operator it gives the result undefined, Its not valid in JSON.
| Z Note: Null and undefined both are primitive
Let's understand it through an example,
var var1
var var2 = null /assigning null value to the variable var2
consolelog(var1 : ${var1}, type : ${typeof(var1)})
consolelog(var2 : ${var2}, type : ${typeoi(var2)})
When we execute the above code, it generates the following output:
Var1 : undefined, type : undefined
var2 : null, type: object
From the above output, we can observe that the value of vari is undefined also its type is undefined
Because we have not assigned any value to the variable var1. The value nullis assigned to the variable var2.
It prints its type as abject. Since null is an assignment value and we can assign it to 2 varlable, Therefore,
JavaScript treats null and undefined relatively equally because both represent an empty value,
16) What are the key differences between GraphQL and REST?
Both, REST and GrashQL, are API design architectures that can be used to develop web services, especially
for data-driven applications.
GraphQL. REST
GraphQL is an API design architecture, but with a RESTis a robust methodology and AP) design
different approach that is much flexible. architecture used to implement web services.
It follows elient-driven architecture. It follows server-driven architecture,
It does not deal with the dedicated resources. It deals with the dedicated resources,
Ithas a single endpoint that takes dynamic parameters, Ithas multiple endpoints.
It provides stateless servers and structured access to It provides stateless servers and flexible
resources, controlled access to resources.
Itis elastic in nature. Itis not rigid in nature.
It supports only JSON format. It supports XML, JSON, HTML, YAML, and
other formats also.
The client defines response data that it needs via a Data represented as resources over HTTP
query language. through URI
It provides synchronous and asynchronous It provides communication
through HTTP only.
synchronous
communication in multiple protocols such as HTTP,
MQTT, AMQP.
Its design based on HTTP (status, methods, and URI). _ Its design based on message exchange
It provides high consistency across all platforms. It is cifficult to achieve high consistency across
all platforms
Development speed is fast. Development speeds slow.
17) Compare fail-fast and fail-safe iterators?
Basis of Fail Fast Iterator Fail Safe Iterator
Comparison
Operates It operates directly on the collection itself. It operates on a cloned copy of
the collection
Exception It throws a ConcurrentModificationException in It does not throw Exception,
Clone Object
modifying the object during the iteration process
No clone object is created during the iteration
A copy or clone object is created
process, during the iteration process,
Memory Itrequires low memory during the process. It requires more memory during
utilization the process
Modification It does notallow modification during iteration. It allows modification during the
iteration process,
Performance tis fast. Itis slightly slower than Fail Fast.
Examples HashMap, ArrayList, Vector, HashSet, ete. CopyOnWriteArrayList,
ConcurrentHashMap, ete
18) What is a connection leak in Java and how can we fix it?
In Java, 2 connection leak is a situation when the developer forgets to close the JDBC connection, itis known
as connection leak. The most common type of Connection Leak experienced in lava development, is when
using a Connection Pool (such as DBCP). We can fixitby closing the connection and giving special attention
to the error handling code.
19) What are the different methods of session management in Servlet?
A session is a conversational state between client and server and it can consist of multiple requests and
responses between client and server. Therefore, HTTP and web server both are stateless, the only way to
maintain a session is when some unique information about the session (session-id) is passed between
server and client in every request and response, We can use the following methods to maintain the session
© User Authentication
HTML Hidden Field
Cookies
URL Rewriting
Session Management AP!
20) How ServletContext is differ from ServletConfig?
ServletContext
ServletContext represents the whole web application
running on a particular JVM and common for all the
serviet.
It is just like a global parameter associated with the
whole application,
It has aoplication-wide scope so define outside servlet
tag in the web file
getServietContextg method is used to get the context,
object.
To get the MIME type of a file or application session
related information is stored using a servlet context
ServletConfig
ServletConfig object represents single servlet
Itis the same as the local parameter associated
with a particular servlet.
Itis a name-value pair defined inside the servlet
section of web.xml files so it has servlet wide
scope.
getServletConfigd method is used to get the
config object
The shopping cart of a user Is a specific to
particular user so here we can use servlet config
object.
21) What is a Request Dispatcher?
RequestDispatcher is an interface that is used to forward the request to another resource that can be HTML,
ISP, or another servlet in the seme application. We can also Use it to include the content of another resource
in the response. The interface contains two methods forward() and included.
forward() method
1. Request 2forwardl--)
see ot servlet >| Servlet2
= 2 response
@) is generated
¥
Response Response
“4 Response is sent back to browser
include() method
1. Request 2.includel-)
>>| Servlet? Servlet2
«_____}
% 4.Final response| __3- Response of servet2
is generated is included inresponse
¥
Response Response
5. Response is
sent back to
browser
22) What are the differences between constructor injection and setter injection?
Constructor Injection Setter Injection
There is no partial injection of dependencies. There can be a partial injection of dependencies.
It does not override the setter injection value. It overrides the constructor injection value if both
are defined.
It always creates a mew instance if any It does not create a new instance if we made any
modification occurs, changes to it.
Using constructor injection is better for too many | Using setter injections better for few properties.
properties.
It makes bean class objects as immutable It makes bean class objects as mutable.
23) How many ways to handle exceptions in the Spring MVC Framework?
Spring MVC Framework provides the following ways to handle exceptions
© Controller-Based: We can define the exception handler method in our controller class.
© Global Exception Handler: Exception handling is a cross-cutting concern that Spring
HandlerExceptionResolver: Any Spring Bean declared in the DispatcherServiet's application
context that implements HandlerExceptionResolver will be used to intercept and process any
exception raised in the MVC system and not handled by a Controller.
24) What are the advantages of Hibernate over JDBC?
There are the following advantages of Hibernate over JDBC:°
Hibernate removes boilerplate code that comes with JDBC API
©. It supports inheritance, associations, and collections that are not present in JDBC API
©. Itimplicitly provides transaction management.
© We need not to write a lot of try-catch block code,
©. InHibernate, HQL is more object-oriented that is closed to Java programming language.
© It provides better performance in comparison to JDBC because Hibernate supports caching while
JDBC does not support caching of queries.
25) What is callback hell and how to fix it?
Callback hell is a phenomenon in JavaScriot in which the developer tries to execute multiple asynchronous
operations together. The nesting of callback functions in such a way, we easily end up with error-prone,
hard to read, and hard to maintain code.
We can easily fix it by using the following methods:
©. Split large functions into smaller functions
© Use Promises
© Use Asyne/ Wait
26) What is double brace initialization in Java and where it is used?
In Java, double brace initialization is a combination of two separate processes, The two consecutive curly
braces {{invelved in it
The first curly brace represents the creation of an anonymous inner class, Remember that the second
curly brace will not be considered in such a case. Itis Just like creating an anonymous inner class.
The second curly brace represents an initialization block that we have seen in it as a class for
initialization. When we use the initialization block for an anonyrnous inner class it becomes Java double
brace initialization, The inner class has a reference to the enclosing outer class. We can use the reference by
using this pointer.
It is used to initialize collections because it is easier to initialize a constant collection using double brace
initialization, The example of double brace initialization is as follows:
import java.util.";
public class Demo
{
public static void main(String args)
Map> map = new HashMap > {{
put ("VEGETABLES’, new HashMap0 {(
put(‘Tomato”, 300};
put(’Onion", 50);
put("Carrot”, 100);
put("Beetroot’, 40);
yh
»
Mh
System.outprintin(map);
}
}
27) How to avoid deadlock in Java?
Avoid Unnecessary Locks: We should use locks only for those members on which it is required
Unnecessary use of locks leads to a deadlock situation. It is recommended that use a lock-free data
structure, If possible, keep your code free from locks. For example, instead of using synchronized ArrayList
use the ConcurrentLlinkedQueue.
Avoid Nested Locks: Another way to avoid deadlocks to avoid giving a lock to multiple threads if we have
already provided a lock to one thread, Since we must avoid allocating a lock ta multiple threads
Using ThreadjoinQ) Method: We can get a deadlock if two threads are waiting for each other to finish
indefinitely using thread join. If a thread has to walt for another thread to finish, it's always best to use join
with the maximum time you want to wait for the thread to finish.
Use Lock Ordering: Always assign a numeric value to each lock. Before acquiring the lock with a higher
numeric value, acquire the locks with a lower numeric value,
Lock Time-out: We can also specify the time for a thread to acquire a lock, If a thread does not acquire a
lock, the thread must wait for a specific time before retrying to acquire a lock.
28) What is a critical section?
The critical section is a part of code in multi-threading that mustbe exclusively modified by any thread. The
critical section is protected by Semaphore or mutex. In Java, there are two ways to protect critical section:
© Using Synchronized keyword
© Using Reentrant Locks
29) What is numeric promotion?
The conversion of a smaller numeric type to a larger numeric type is
own as numeric promotion. In this
type, byte, char, and short values are converted to int values. The int values are converted to long values, if
necessary. The long and float values are converted to double values, as needed.
30) What is the SOLID principle in Java?
In Java, SOLID principles are an object-oriented approach that are applied to software structure design. Itis
conceptualized by Rebert C. Martin (also known as Uncle Bob). These five principles have changed the
world of object-oriented programming, and also changed the way of writing software It also ensures that
the software is modular, easy to understand, debug, and refactor.
The word SOLID acronym for:
© Single Responsibility Principle (SRP)
© Open-Closed Principle (OCP)
©. Liskov Substitution Principle (LSP)
© Interface Segregation Principle (ISP)
© Dependency Inversion Principle (DIP)