Full Stack Developer Interview Questions Java 2023 Javatpoint
Full Stack Developer Interview Questions Java 2023 Javatpoint
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