JAVA VIVA ??
JAVA VIVA ??
What is Java?
Java is a programming language and a platform. Java is a high level, robust, object-oriented and
secure programming language.
Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995.
James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a
registered company, so James Gosling and his team changed the name from Oak to Java.
1) Standalone Application
2) Web Application
An application that runs on the server side and creates a dynamic page is called a web application.
Currently, Servlet, JSP, Struts, Spring, Hibernate, JSF, etc. technologies are used for creating web
applications in Java.
3) Enterprise Application
An application that is distributed in nature, such as banking applications, etc. is called an enterprise
application. It has advantages like high-level security, load balancing, and clustering. In Java, EJB is
used for creating enterprise applications.
4) Mobile Application
An application which is created for mobile devices is called a mobile application. Currently, Android
and Java ME are used for creating mobile applications.
1) Java SE (Java Standard Edition) It is a Java programming platform. It includes Java programming
APIs such as java.lang, java.io, java.net, java.util, java.sql, java.math etc. It includes core topics like
OOPs, String, Regex, Exception, Inner classes, Multithreading, I/O Stream, Networking, AWT, Swing,
Reflection, Collection, etc.
2) Java EE (Java Enterprise Edition)
It is an enterprise platform that is mainly used to develop web and enterprise applications. It is built
on top of the Java SE platform. It includes topics like Servlet, JSP, Web Services, EJB, JPA, etc.
4) JavaFX
It is used to develop rich internet applications. It uses a lightweight user interface API.
Loads code
Verifies code
Executes code
JVM Architecture
1) Classloader
Classloader is a subsystem of JVM which is used to load class files. Whenever we run the java
program, it is loaded first by the classloader. There are three built-in classloaders in Java.
Bootstrap ClassLoader: This is the first classloader which is the super class of Extension classloader.
It loads the rt.jar file which contains all class files of Java Standard Edition like java.lang package
classes, java.net package classes, java.util package classes, java.io package classes, java.sql package
classes etc.
Extension ClassLoader: This is the child classloader of Bootstrap and parent classloader of System
classloader. It loades the jar files located inside $JAVA_HOME/jre/lib/ext directory.
System/Application ClassLoader: This is the child classloader of Extension classloader. It loads the
classfiles from classpath. By default, classpath is set to current directory. You can change the
classpath using "-cp" or "-classpath" switch. It is also known as Application classloader.
2) Class(Method) Area
Class (Method) Area stores per-class structures such as the runtime constant pool, field and method
data, the code for methods.
3) Heap
It is the runtime data area in which objects are allocated.
4) Stack
Java Stack stores frames. It holds local variables and partial results, and plays a part in method
invocation and return.
Each thread has a private JVM stack, created at the same time as thread.
A new frame is created each time a method is invoked. A frame is destroyed when its method
invocation completes.
PC (program counter) register contains the address of the Java virtual machine instruction currently
being executed.
7) Execution Engine
It contains:
A virtual processor
Just-In-Time(JIT) compiler: It is used to improve the performance. JIT compiles parts of the byte code
that have similar functionality at the same time, and hence reduces the amount of time needed for
compilation. Here, the term "compiler" refers to a translator from the instruction set of a Java virtual
machine (JVM) to the instruction set of a specific CPU.
Java Native Interface (JNI) is a framework which provides an interface to communicate with another
application written in another language like C, C++, Assembly etc. Java uses JNI framework to send
output to the Console or interact with OS libraries.
JDK contains JRE + development tools. The Java Development Kit (JDK) is a software development
environment which is used to develop java applications and applets. It physically exists.
The JRE is the on-disk system that takes your Java code, combines it with the necessary libraries, and
starts the JVM to execute it JRE is the container, JVM is the content
Java Variables
A variable is a container which holds the value while the Java program is executed. A variable is
assigned with a data type.
Variable is a name of memory location. There are three types of variables in java: local, instance and
static.
1) Local Variable
A variable declared inside the body of the method is called local variable. You can use this variable
only within that method and the other methods in the class aren't even aware that the variable
exists.
2) Instance Variable
A variable declared inside the class but outside the body of the method, is called an instance
variable. It is not declared as static.
It is called an instance variable because its value is instance-specific and is not shared among
instances.
3) Static variable
A variable that is declared as static is called a static variable. It cannot be local. You can create a
single copy of the static variable and share it among all the instances of the class. Memory allocation
for static variables happens only once when the class is loaded in the memory.
Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and
double.
Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays.
Java Operator Precedence
Arithmetic multiplicative * / %
additive + -
equality == !=
bitwise exclusive OR ^
bitwise inclusive OR |
logical OR ||
Ternary ternary ? :
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
Object: Any entity that has state and behavior is known as an object.
Class:Collection of objects is called class. It is a logical entity.
A class can also be defined as a blueprint from which you can create an individual
object.
Inheritance: When one object acquires all the properties and behaviors of a parent
object, it is known as inheritance. It provides code reusability. It is used to achieve
runtime polymorphism.
Polymorphism: If one task is performed in different ways, it is known as
polymorphism.
Abstraction: Hiding internal details and showing functionality is known as
abstraction.
Encapsulation: Binding (or wrapping) code and data together into a single
unit are known as encapsulation
Coupling
Coupling refers to the knowledge or information or dependency of
another class. It arises when classes are aware of each other.
Cohesion
Cohesion refers to the level of a component which performs a single well-
defined task. A single well-defined task is done by a highly cohesive
method. The weakly cohesive method will split the task into separate
parts.
------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
---------------- ------------------------ ------------------------- --------------------------
1.Spring Boot :
Spring Boot is a Spring module which provides RAD (Rapid Application Development)
feature to Spring framework.
It is used to create stand alone spring based application that you can just run because
it needs very little spring configuration.
2. what is DispatcherServlet and how it works?
DispatcherServlet acts as front controller for Spring based web applications. It creates
DispatcherServletWebApplicationContext and this will instantiates the backend controller and
based on the response
from the backend controller it identifies the view and send it to the client.(dispatches requests to
the handler methods
present in controller class).
3.Rest Template :
Rest Template is used to create applications that consume RESTful Web Services. You
can use the exchange() method to consume the web services for all HTTP methods.
0r
RestTemplate. is the central class within the Spring framework for executing
synchronous HTTP requests on the client side. Like Spring JdbcTemplate,
RestTemplate. is also a high-level API, which in turn is based on an HTTP client
or
Rest Template is used to create applications that consume RESTful Web Services. You
can use the exchange() method to consume the web services for all HTTP methods. The
code given below shows how to create Bean for Rest Template to auto wiring the Rest
Template object.
or
The ability to execute the SonarQube analysis via a regular Maven
goal makes it available anywhere Maven is available (developer build, CI
server, etc.), without the need to manually download, setup, and
maintain a SonarQube Runner installation
or
Maven is a powerful project management tool that is based on POM (project object
model). It is used for projects build, dependency and documentation. It simplifies
the build process like ANT. ... In short terms we can tell maven is a tool that can be
used for building and managing any Java-based project.
Or
A Spring MVC is a Java framework which is used to build web applications. It follows
the Model-View-Controller design pattern. It implements all the basic features of a
core spring framework like Inversion of Control, Dependency Injection.
7.What is spring
Spring is an open source development framework for enterprise Java. ... Basically
Spring is a framework for dependency-injection which is a pattern that allows to build
very decoupled systems. Spring is a good framework for web development.
Or
• Directive tags
• Standard action tags
• Scriplet tags
Directive tags:
• Page directive
• Include directive
• Taglib directive
• Forward action
• Include action
• Use bean action
Scriplet tags:
• Scriplet tag
• Expression tag
• Declaration tag
10.Explain life cycle of a JSP?
A JSP page is internally converted into the servlet. JSP has access to the entire
family of the Java API including JDBC API to access enterprise database. Hence,
Java language syntax has been used in the java server pages (JSP). The JSP pages
are more accessible to maintain than Servlet because we can separate designing
and development. It provides some additional features such as Expression
Language, Custom Tags, etc.
It would be performed within the same It would occur in two classes which
class. have parent-child relationship.
Return type of the methods can be Overriding method should have same
different. return type as that of the parent or it
can have co-variant return type.
{ Pojo stands for plan old java objects: it will have it’s own behaviour along
with some variables setter & getters}
or
1.It is an architecture which tells that model part should communicate with
database
2.View part should communicate with the client where as controller should
establish communication in between model and view
3.model contains java beans file,java beans is a normal java class which should
contain a constructor, setter & getter.
Or
1. Test
2. Spring Core Container
3. AOP, Aspects and Instrumentation
4. Data Access/Integration
5. Web
18.View resolver:
All the handler methods in the controller returns the logical view name in String,View or
ModelAndView.
These logical views are mapped to actual views by using view resolver.
19.what is spring jpa data
It is one of the modules in the spring frameworks. spring data jpa provides jpa
template class to integrate spring application with jpa.
20.What is object?
Object − Objects have states and behaviors. ... An object is an instance of a class. Class −
A class can be defined as a template/blueprint that describes the behavior/state that the
object of its type support.
Or
Object is nothing but instance of class. It has its own state, behaviour and identity
Or
The Object is the real-time entity having some state and behavior. In Java, Object is an
instance of the class having the instance variables as the state of the object and the methods
as the behavior of the object. The object of a class can be created by using the new keyword.
24.Isolation Level:
The Isolation level determines what happens during the concurrent (simultaneous) use
of the same transaction. Dirty Reads return different results within a single transaction
when an SQL operation accesses an uncommitted or modified record created by another
transaction.
26.Spring MVC
Spring MVC stands for Spring Model-View-Controller is a framework that is designed with the
help of dispatcher servlet which dispatches requests to the specific controllers with the help
of annotations and that controller will return the response again to the dispatcher servlet i.e. it
will get data and view name and the view technology will fetch the data from the controller
then that page goes from dispatcher servlet to the client.
Or
Or
A Spring MVC is a Java Framework which is used to develop dynamic web applications.
It implements all the basic features of a core spring framework like Inversion of Control
and Dependency Injection. It follows the Model-View-Controller design pattern.
Here,
Model - A model contains the data of the application. Data can be a single object or
a collection of objects.
View - A view represents the provided information in a particular format. So, we can
create a view page by using view technologies like JSP+JSTL, Apache Velocity,
Thymeleaf, and FreeMarker.
28.Constructor Injection
Constructor Injection is the act of statically defining the list of required Dependencies
by specifying them as parameters to the class's constructor. ... The class that needs
the Dependency must expose a public constructor that takes an instance of the required
Dependency as a constructor argument
29. JPA:
30. Interface:
An interface in the Java programming language is an abstract type that is used to specify
a behavior that classes must implement. They are similar to protocols. Interfaces are
declared using the interface keyword, and may only contain method signature and
constant declarations.
Or
It will get the request find the appropriate controller and do send back that response to the
client it as a role of dispatcher servlet
--file name should be servlet name hyphen servlet. ispatcher servlet is also some files within
our Applications so here that file will consist of some configurations within that.
32. Encapsulation
Is an attribute of an object it contains all data which is hidden.That hidden data can be restricted to
the members of that class. Levels are public,protected,private,internal and protected internal.
Ex: It is wrapped with diff medicines in a capsule,all meedeicine is encapsulated inside a capsule.
A java class is an example of encapsulation java bean is fully encapsulated class becoz all the data
members are private here.
33.Object:
Object − Objects have states and behaviors. Example: A dog has states - color, name,
breed as well as behaviors – wagging the tail, barking, eating. An object is an instance of a
class. Class − A class can be defined as a template/blueprint that describes the
behavior/state that the object of its type support.
Or
Object:Is nothing but an instance of class.It has its own state ,behaviour and identity.
Class: a class is simply a representation of atype of object.It is blueprint or plan or template
that describes the detail of an object.
34.Inheritance and example
Inheritance is a concept where one class shares the structure and behaviour defined in another
class . if inheritance applied to one class is called single inheritance and if it depends on multiple
classes,then it is called multiple inheritance.
Superclass : the class whose features are inherited is known as superclass {parent class}
Subclass : The class that inherits the other class is known as subclass { child class}
Ex:
In real -life example of inheritance is child and parents,all the properties of a father are inherited by
his son/
*What is Maven?
Maven is an automation and management tool developed by Apache Software
Foundation. It is written in Java Language to build projects written in C#, Ruby,
Scala, and other languages. It allows developers to create projects, dependency,
and documentation using Project Object Model and plugins. It has a similar
development process as ANT, but it is more advanced than ANT.
Maven can also build any number of projects into desired output such as jar,
war, metadata.
It was initially released on 13 July 2004. In the Yiddish language, the meaning of
Maven is “accumulator of knowledge.”
ANT stands for Another Neat Tool. It is a Java-based build tool from computer
software development company Apache.
38.HTTP:
HTTP stands for Hypertext Transfer Protocol. It is a set of rule which is used for
transferring the files like, audio, video, graphic image, text and other multimedia files
on the WWW (World Wide Web). HTTP is a protocol that is used to transfer the
hypertext from the client end to the server end, but HTTP does not have any security.
Whenever a user opens their Web Browser, that means the user indirectly uses HTTP.
39. Httpservlet
The HttpServlet class extends the GenericServlet class and implements Serializable interface.
-It provides http specific methods such as doGet, doPost, doHead, doTrace etc.
41.Spring Security
Spring Security is a powerful and highly customizable authentication and access-
control framework. It is the de-facto standard for securing Spring-based applications.
Or
Spring security with example:-------------
Or
Introduction
Spring Security is a framework which provides various security features like:
authentication, authorization to create secure Java Enterprise Applications.
It is a sub-project of Spring framework which was started in 2003 by Ben Alex. Later
on, in 2004, It was released under the Apache License as Spring Security 2.0.0.
It overcomes all the problems that come during creating non spring security
applications and manage new server environment for the application.
This framework targets two major areas of application are authentication and
authorization. Authentication is the process of knowing and identifying the user that
wants to access.
42.Develop Platform:
Java is a general-purpose, class-based, object-oriented programming language designed for
having lesser implementation dependencies. It is a computing platform for application
development. Java is fast, secure, and reliable, therefore.
43. @ModelAttribute
@ModelAttribute is a Spring-MVC specific annotation used for preparing the model data.
It is also used to define the command object that would be bound with the HTTP request data.
The annotation works only if the class is a Controller class (i.e. annotated with @Controller).
44. Reponsebody
The response body consists of the resource data requested by the client. In our example,
we requested the book's data, and the response body consists of the different books present
in the database along with their information
45. Exceptions in java
In Java “an event that occurs during the execution of a program that disrupts the
normal flow of instructions” is called an exception. This is generally an unexpected or
unwanted event which can occur either at compile-time or run-time in application code.
47.List
The Java. util. List is a child interface of Collection. It is an ordered collection of objects in
which duplicate values can be stored. ... List Interface is implemented by ArrayList,
LinkedList, Vector and Stack classes.
48 JDBC
Java Database Connectivity (JDBC) is an application programming interface (API) for the
programming language Java, which defines how a client may access a database. ... It
provides methods to query and update data in a database, and is oriented toward relational
databases.
49.JPA
JPA is just a specification that facilitates object-relational mapping to manage
relational data in Java applications. It provides a platform to work directly with objects
instead of using SQL statements
Or
The Java Persistence API (JPA) is a specification that defines how to persist data in Java
applications. The primary focus of JPA is the ORM layer. mvc is one of the most popular
Java ORM frameworks in use today.
50.Spring MVC
A Spring MVC is a Java framework which is used to build web applications. It follows the
Model-View-Controller design pattern. It implements all the basic features of a core spring
framework like Inversion of Control, Dependency Injection.
51.Difference between ArrayList and LinkedList
4. Multiple null elements can be stored. 4. Null element can store only once.
53.Collection
The Collection in Java is a framework that provides an architecture to store and
manipulate the group of objects. Java Collections can achieve all the operations that you
perform on a data such as searching, sorting, insertion, manipulation, and deletion. Java
Collection means a single unit of objects.
59.Collection
Java Collection means a single unit of objects. Java Collection framework provides
many interfaces (Set, List, Queue, Deque) and classes (ArrayList,
Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet)
It is used to represent a group of individual It defines several utility methods that are used to
objects as a single unit. operate on collection.
There are given 6 steps to create a servlet example. These steps are required for all
the servers.
The mostly used approach is by extending HttpServlet because it provides http request
specific method such as doGet(), doPost(), doHead() etc.
The doGet() method is used for getting the information from server while the doPost()
method is used for sending information to the server.
Here, we are going to use apache tomcat server in this example. The steps are as
follows:
GenericServlet
GenericServlet is an abstract class which implements Servlet and
ServletConfig interface. GenericServlet class can also be used to create a
Servlet. GenericServlet class is part of the Servlet API and the full path to import
this class is javax. servlet. GenericServlet.
64.What is servlet workflow?
Web container is responsible for managing execution of servlets and JSP
pages for Java EE application. When a request comes in for a servlet, the
server hands the request to the Web Container. Web Container is responsible
for instantiating the servlet or creating a new thread to handle the request.
CRUD is an acronym that stands for Create, Read, Update, and Delete. These are the four
most basic operations that can be performed with most traditional database systems and
they are the backbone for interacting with any database.
Search for: How are CRUD operations implemented?
68. Annotations
an annotation is a form of syntactic metadata that can
be added to Java source code.
Or
Java Annotation is a tag that represents the metadata i.e. attached with class, interface,
methods or fields to indicate some additional information which can be used by java
compiler and JVM.
First, we will learn some built-in annotations then we will move on creating and using
custom annotations.
Or
93.servlet config
94.servlet context
95.better way of maintaining session
98.
99.implicit objects of jsp
100.JDBC
101.Types of JDBC
Statement PreparedStatement
It is used when SQL query is to be It is used when SQL query is to be executed
executed only once. multiple times.
You can not pass parameters at runtime. You can pass parameters at runtime.
Used for CREATE, ALTER, DROP Used for the queries which are to be executed
statements. multiple times.
Performance is very low. Performance is better than Statement.
It is base interface. It extends statement interface.
Used to execute normal SQL queries. Used to execute dynamic SQL queries.
We can not used statement for reading We can used Preparedstatement for reading
binary data. binary data.
It is used for DDL statements. It is used for any SQL Query.
We can not used statement for writing We can used Preparedstatement for writing
binary data. binary data.
No binary protocol is used for
communication. Binary protocol is used for communication.
103. java 8 feature
Feature Name Description
Lambda expression A function that can be shared or referred to as an object.
Functional Interfaces
Single abstract method interface.
Method References Uses function as a parameter to invoke a method.
It provides an implementation of methods within interfaces
Default method enabling 'Interface evolution' facilities.
Stream API Abstract layer that provides pipeline processing of the data.
New improved joda-time inspired APIs to overcome the
Date Time API drawbacks in previous versions
Wrapper class to check the null values and helps in further
Optional processing based on the value.
Nashorn, JavaScript An improvised version of JavaScript Engine that enables
Engine JavaScript executions in Java, to replace Rhino.
Both Set and Map interfaces are used to store a collection of objects as a single unit. The
main difference between Set and Map is that Set is unordered and contains different
elements, whereas Map contains the data in the key-value pair.
107.Unit Testing
Unit testing involves the testing of each unit or an individual component of the software
application. It is the first level of functional testing. The aim behind unit testing is to validate
unit components with its performance.
A unit is a single testable part of a software system and tested during the development phase
of the application software.
The purpose of unit testing is to test the correctness of isolated code. A unit component is an
individual function or code of the application. White box testing approach used for unit
testing and usually done by the developers.
Whenever the application is ready and given to the Test engineer, he/she will start checking
every component of the module or module of the application independently or one by one,
and this process is known as Unit testing or components testing.
[8:55 am, 02/09/2021] Sravani: Context hierarchy : defines 2 types of web application contexts- root
and servlet / child web application context
[8:55 am, 02/09/2021] Sravani: Context configuration helps in loading the spring configurations from
xml files.
120.valid :
The @Valid annotation is used to mark nested attributes in particular. This triggers the
validation of the nested object. For instance, in our current scenario, let's create a
UserAddress object: public class UserAddress { @NotBlank private String countryCode; //
standard constructors / setters / getters / toString
--------------------------------------------------------------------------------------------------
121)@ModelAttribute:
For parameter annotations, think of @ModelAttribute as the equivalent of @Autowired +
@Qualifier i.e. it tries to retrieve a bean with the given name
from the Spring managed model. If the named bean is not found, instead of throwing an error or
returning null, it implicitly takes on the role of @Bean i.e.
Create a new instance using the default constructor and add the bean to the model.
The @ModelAttribute is an annotation that binds a method parameter or method return value to a
named model attribute and then exposes it to a web view.
122)@Autowired:
To autowire a relationship between the collaborating beans without using constructor arguments
and property tags that reudces rhe amount of XML configaration.It
automatically injects the dependent beans into the associated references of a POJO class.
Or
The @Autowired annotation can be used to autowire bean on the
setter method just like @Required annotation, constructor, a
property or methods with arbitrary names and/or multiple
arguments.
123)@RequestMapping :
Most imp annotation.This maps http request to handler methods of MVC and REST controllers.Can
be applied to class level/method level in a controller.
124)Bean :
In Spring, the objects that form the backbone of your application and that are managed by the
Spring IoC container are called beans.
A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC
container.
126)ORM.XML :
The standard JPA orm. xml file applies metadata to the persistence unit. It provides support for all of
the JPA 2.0 mappings.
You can use this file instead of annotations or to override JPA annotations in the source code.
131)Annotations :
@Entity and @Id . The @Entity annotation specifies that the class is an entity and is mapped to a
database table.
@Table annotation specifies the name of the database table to be used for mapping.
They are serializable, have a zero-argument constructor, and allow access to properties using getter
and setter methods. The name "Bean"
was given to encompass this standard, which aims to create reusable software components for Java.
View-responsible to generate/select the User interface and present the data to the end user
Controller-Intercepts all the requests/commands sent to the application and updates the view.
It implements all the basic features of a core spring framework like Inversion of Control, Dependency
Injection.
A Spring MVC provides an elegant solution to use MVC in spring framework by the help of
DispatcherServlet.
Here, DispatcherServlet is a class that receives the incoming request and maps it to the right
resource such as controllers, models, and views.
136)Application context :
The ApplicationContext is the central interface within a Spring application that is used for providing
configuration information to the application.
It represents the Spring IoC container and is responsible for instantiating, configuring, and
assembling the beans.
137)Binding result :
BindingResult holds the result of a validation and binding and contains errors that may have
occurred.
The BindingResult must come right after the model object that is validated or else Spring fails to
validate the object and throws an exception
140)View resolver :
Spring MVC Framework provides the ViewResolver interface, that maps view names to actual views.
It also provides the View interface, which addresses the request of a view to the view technology.
(or)
In Spring MVC based application, the last step of request processing is to return the logical view
name.
Here DispatcherServlet has to delegate control to a view template so the information is rendered.
This view template decides that which view should be rendered based on returned logical view
name.
These view templates are one or more view resolver beans declared in the web application context.
These beans have to implement the ViewResolver interface for DispatcherServlet to auto-detect
them. Spring MVC comes with several ViewResolver implementations.
the logical view names to directly view files under a certain pre-configured directory.
142)@Valid :
value="txmanager" : To avoid transcational begin and commit after persisting every data,,we use
this.
@Transactional : there are two types if transaction management Global(managed byy spring
containers) and local(database)
144)Inversion of control :
Run time will be able to create objects and give it back to the code.
146)@RepositoryDefnition :
customization to expose selected methods in the interface can be achieved.
extending CRUD will provde the complete set of methods avalable for entity manipulation.
@Repository: annotation is used to indicate that the class provides the mechanism for storage,
retrieval, search, update and delete operation on objects.
1. Spring Session Core: Provides API and core support for session
management.
2. Spring Session JDBC: provides session management using relational
database.
3. Spring Session Data Redis: provides session management implementation
for Redis database.
4. Spring Session Hazelcast: provides session management support using
Hazelcast.
Iterating We use for loop or for each loop to iterate We use an iterator to iterate over
Values over an array. ArrayList.
Type-Safety We cannot use generics along with array ArrayList allows us to store
because it is not a convertible type of array. only generic/ type, that's why it is
type-safe.
Length Array provides a length variable which ArrayList provides the size() method
denotes the length of an array. to determine the size of ArrayList.
Adding We can add elements in an array by using Java provides the add() method to
Elements the assignment operator. add elements in the ArrayList.
153.What is lambda?
Ans: A lambda expression is a short block of code which takes in parameters and
returns a value.
JPA Hibernate
Java Persistence API (JPA) defines the management Hibernate is an Object-Relational Mapping
of relational data in the Java applications. (ORM) tool which is used to save the state of
Java object into the database.
It is just a specification. Various ORM tools It is one of the most frequently used JPA
implement it for data persistence. implementation.
It uses EntityManager interface to create, read, and It uses Session interface to create, read, and
delete operations for instances of mapped entity delete operations for instances of mapped
classes. This interface interacts with the persistence entity classes. It behaves as a runtime interface
context. between a Java application and Hibernate.
It uses Java Persistence Query Language (JPQL) as It uses Hibernate Query Language (HQL) as an
an object-oriented query language to perform object-oriented query language to perform
database operations. database operations.
156.Duration of sprint.
Ans: That is, the Team needs to be able to get Stories Done. It's a rule of Scrum
that a Sprint should never be longer than one month. Generally speaking, the Sprint
length should be approximately three times as long as it takes to Swarm on an
average medium-size Story and get it Done.
161.What is Agile?
162.What is Devops?
The key technical differences between an abstract class and an interface are: Abstract
classes can have constants, members, method stubs (methods without a body) and
defined methods, whereas interfaces can only have constants and methods stubs
166.What is entity life cycle?
The life cycle of entity objects consists of four states: New, Managed, Removed and
Detached. When an entity object is initially created its state is New. In this state the object is
not yet associated with an EntityManager. persistence.
A servlet life cycle can be defined as the entire process from its creation till the
destruction. ... The servlet is initialized by calling the init() method. The servlet calls
service() method to process a client's request. The servlet is terminated by calling the
destroy() method.
….>
The web container maintains the life cycle of a servlet instance. Let's see the life cycle
of the servlet:
there are three states of a servlet: new, ready and end. The servlet is in new state if
servlet instance is created. After invoking the init() method, Servlet comes in the ready
state. In the ready state, servlet performs all the tasks. When the web container invokes
the destroy() method, it shifts to the end state.
1) Servlet class is loaded
The classloader is responsible to load the servlet class. The servlet class is loaded when
the first request for the servlet is received by the web container.
The web container calls the init method only once after creating the servlet instance. The init metho
the servlet. It is the life cycle method of the javax.servlet.Servlet interface. Syntax of the init method
1. public void init(ServletConfig config) throws ServletException
PUT POST
Generally, in practice, always use PUT for Always use POST for
UPDATE operations. CREATE operations.
170.methods of http
The primary or most commonly-used HTTP methods are POST, GET, PUT, PATCH,
and DELETE. These methods correspond to create, read, update, and delete (or
CRUD) operations, respectively.
174.@autowiring
Automatic injection of beans
175.Diff b/w crud and jpa repositories:
Difference between JPA and CRUD Repositories:
176.jpa vendors
Hibernate
Eclipselinks
ibatis
177. @configuration
Used by spring containers as a source of bean definition and it
is a class level annotation
178. Rest
Representational state transfer it is an architectural pattern used
to web services which interact with each other through HTTP
protocol.
179. Lambda
(parameter)->(expressions)
300. @contextConfiguration
@ContextConfiguration defines class-level metadata that is used to determine how to
load and configure an ApplicationContext for integration tests.
If the list's list-iterator does not support the set operation then
an UnsupportedOperationException will be thrown when replacing the first element.
The boolean value denotes if index is found the set or not. The integer value contains
the integer stored at index in the set. If the boolean value is set true, which indicates
index to be a vakid index, print the integer value stored in the pair. Otherwise print
“Invalid index”.
……///////////
406) try-with-resources
In Java, the try-with-resources statement is a try statement
that declares one or more resources. The resource is as an
object that must be closed after finishing the program. The
try-with-resources statement ensures that each resource is
closed at the end of the statement execution.
408) what is Inheritance
Inheritance in Java is a mechanism in which one object acquires
all the properties and behaviors of a parent object. ... The idea
behind inheritance in Java is that you can create new classes
that are built upon existing classes. When you inherit from an
existing class, you can reuse methods and fields of the parent
class.
) rest API
REST or RESTful API design (Representational State Transfer)
is designed to take advantage of existing protocols. ... This
means that developers do not need to install libraries or
additional software in order to take advantage of a REST API
design.
It has 4 components
602) @autowired
@Autowired annotation – We can use Spring @Autowired
annotation for spring bean autowiring. @Autowired annotation can
be applied on variables and methods for autowiring byType. We
can also use @Autowired annotation on constructor for
constructor based spring autowiring.