Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

251.

What is the use of snapshot in Maven?

Answer»

In Maven, SNAPSHOTS are used for ACTIVE projects. You can entirely rely on the snapshot RELEASE when you have SOFTWARE development projects are active. Here, Maven attempt to download the snapshots, when the user runs the build, from a repository.

252.

How do you check if you have Maven installed?

Answer»

Follow the below-written STEPS to check the PROPER installation of MAVEN:-

  • MAKE a version check by running mvn -V from the command line
  • You would see resembling output if you have Maven tool.
  • You are all set to use Maven

Learn more about Best Maven Interview Questions with us.

253.

What is Maven's order of inheritance?

Answer»

It is ONE of the most common Maven INTERVIEW Question and most accessible to ANSWER and remember.

The order of Maven inheritance is as below-
  • Parent Pom
  • Project Pom
  • Settings
  • CLI Parameters
254.

What is Maven build life cycle?

Answer»

Maven BUILD life cycle is the SEQUENCE of the STEPS for the execution of the goals and tasks of any Maven project. The categories under Maven build life cycle are default, clean and site. Here, the default lifecycle handles the deployment of the project and WHEREAS, the clean life cycle considers the CLEANING of the project. The task of handling the creation of the documentation of the project is dealt with by site lifecycle.

255.

Explain the difference between Apache Ant and Maven?

Answer»
S.noApache AntMaven
1.No formal CONVENTIONS arise the REQUIREMENT of PROVIDING project structure information in the build.xml fileAvailability of the conventions by placing COMPILED code and source code i.e., no information sharing requirement in the project structure in pom.xml.file
2.The absence of life cycle in Apache AntPresence of the life cycle in Maven
3.It is a toolbox mainly of the building natureIt is a framework primarily project management tool
256.

What are the types of Maven repository?

Answer»

There are THREE TYPES of MAVEN REPOSITORY, namely-

  • Local repository
  • Central repository
  • Remote repository
257.

What is the use of Maven repository?

Answer»

It is the directory of the JAR files which are packaged and that too with some metadata which are POM files. These are the files used for DOWNLOADING DEPENDENCIES of your dependencies TILL the time when all of them are DOWNLOADED. These are put into the local machine.

258.

What does Maven install do?

Answer»

Maven INSTALL is used for framing a PROJECT configuration-based DEPENDENCY tree such as pom.xml. On an MVN install, framing project is DONE on all the subjects under downloads/compiles and super pom.xml for all the required components in the directory

259.

What is the purpose of Maven?

Answer»
  • To ease handling of the dependencies on the availability of a lot of dependencies
  • Updating the dependencies by choosing the CORRECT update version ID
  • Facilitating the process of building, integrating and TESTING of the program ALONG with handling it continuously
  • Compiling the source code, generating DOCUMENTS from it and packaging the COMPILED code.
260.

What is POM in maven?

Answer»

POM, PROJECT Object Model is the fundamental work unit in Maven. Basically, it is an XML file CONTAINING details of the configuration and project INFORMATION with the help of Maven for building the project. The best thing is the AVAILABILITY of the default values for the PROJECTS.

261.

What are the advantages of Maven?

Answer»
  • Helps in BETTER debugging
  • Enhanced collaboration
  • Clean GENERATED FILES from the project such as .class files
  • Improved dependency management
  • Project structure CONSISTENCY
262.

What do you mean by Maven and why it is used?

Answer»

A maven is a tool used for software project management and comprehension. Most of the times it is used with projects or software developed in Java, and other PROGRAMMING languages such as RUBY and C#.

This software project management tool is used for-
  • documentation, MANAGING builds, SCM (software configuration management)
  • reporting, releases, dependencies
  • project compilation WITHIN the IDE with the help of several IDES.
263.

List some of the Design Patterns used in the Spring Framework?

Answer»

Here are some of the DESIGN PATTERNS USED in SPRING:

  • MVC
  • Front controller
  • View Helper
  • Singleton
  • Prototype
  • Factory
  • Builder
  • Template
  • Proxy
  • DI/IOC
264.

What do you mean by ViewResolver in Spring?

Answer»

Like all MVC frameworks that provide a WAY to work with views, SPRING offers the same feature through the VIEW resolvers. The view resolvers enable the developers to render MODELS in the browser without the need to implement a specific view METHOD. In ViewResolver, you can map view names with actual views. Some of the view resolvers in the Spring framework are InternalResourceViewResolver, ResourceBundleViewResolver, and XmlViewResolver.

265.

Explain the use of Spring Security?

Answer»

Spring Security is one of the security modules in the Spring FRAMEWORK. BASED on the Java SE/Java EE framework, it provides authentication and authorization to web and ENTERPRISE applications. This powerful and highly customizable framework is the de-facto standard for securing all spring-based apps.

19. What do you mean by @controller annotation in spring?

@Controller annotation is a specialization of @Component class that ALLOWS the implementation class to be detected through classpath scanning. @Controller annotation annotates Classic controllers. @Controller annotation is used in MVC framework in combination with @RequestMapping annotation in request handling.

266.

What do you mean by DAO in Spring?

Answer»

DAO or Data Access Object is a design pattern where DAO is an object, which provides an abstract INTERFACE to a DATABASE or some other type of persistence mechanisms. This support AIMS at working with data access technologies like Hibernate and JPA EASY and CONSISTENT.

267.

Explain the difference between Singleton and prototype bean in spring?

Answer»
 SingletonPrototype
1.Single bean to a single OBJECTSingle bean to any number of objects
2.Returns same object each TIME it GETS injectedCreates a new object each time it gets injected
3.Use for STATELESS BEANSUse for stateful beans
268.

What do you mean by @qualifier in spring?

Answer»

The @Qualifier annotation in SPRING is used in CASES where the developer has created more beans of the same type but only wants to wire one of them with the said PROPERTY. The @Qualifier annotation can be used with @Autowired for removing the confusion of SPECIFYING and identifying the exact bean to be wired.

269.

Explain the difference between @autowired and @inject?

Answer»
 AutowiredInject
1.Spring's LEGACY annotationAvailable from Spring 3 onwards
2.Process to figure out DEPENDENCIES of a beanStandard annotation for DI
3.Contains 'required' attributeDoes not CONTAIN 'required' attribute
270.

What do you mean by configuration annotation in spring?

Answer»

Configuration annotation is a part of the spring framework. It indicates that class includes @BEAN definition METHODS. This helps the container process the class and GENERATE BEANS for using in the application and generating definitions and service requests at the runtime.

271.

What do you mean by Autowiring in spring?

Answer»

The Autowiring FEATURE enables developers to inject DEPENDENCIES in the object implicitly. Autowiring internally USES the setter or constructor INJECTION. This feature cannot be used for injecting primitive or string values, and it only WORKS with reference.

272.

What are setter injection and constructor injection in spring?

Answer»

Setter Injection is a type of dependency injection (DI) in which the framework uses a setter METHOD to inject dependent objects into the client. The CONTAINER first calls the no-argument constructor and later it calls the setters. Such setter-based injections can work even if dependencies are injected using the constructor.

Constructor injection uses a constructor for injecting dependencies on Spring-managed BEANS. The constructor DI is achieved when the container initiates a CLASS constructor with arguments, each argument REPRESENTING dependencies on other classes.

273.

What do you mean by BeanFactory in spring?

Answer»
274.

What is BeanFactory and ApplicationContext in Spring?

Answer»

BeanFactory is the container that instantiates, manages and configures beans. Beans usually collaborate with each another and SHARE dependencies, which are shown in the data used by the BeanFactory.

The APPLICATIONCONTEXT is the INTERFACE within a SPRING application for offering configuration information to the application.

275.

Explain the different types of spring container?

Answer»

Spring provides 2 types of containers:

  • Spring BEANFACTORY Container : It provides basic support for DI and is defined by org.springframework.beans.factory.BeanFactory INTERFACE. BeanFactory and related interfaces are AVAILABLE in Spring for backward compatibility with third-party frameworks.
  • Spring ApplicationContext Container : It adds enterprise-specific functionalities to INTERESTED event LISTENERS. It is defined by org.springframework.context.ApplicationContext interface.
276.

What do you mean by AOP?

Answer»

Aspect-oriented PROGRAMMING or AOP is a programming approach that allows different properties of a program to DETERMINE how they are compiled into a program. You can use AOP with object-oriented programming or OOP.

277.

List the modules used in Spring framework?

Answer»

Spring framework has 7 modules.

  • The Core container MODULE
  • Application context module
  • AOP module (Aspect Oriented PROGRAMMING)
  • JDBC abstraction and DAO module
  • O/R mapping INTEGRATION module (Object/Relational)
  • Web module
  • MVC framework module
6. What is the LATEST Spring version? Spring Framework 5.0 GA
278.

What do you mean by dependency injection and how does it work?

Answer»

Dependency Injection or DI is a DESIGN pattern that implements inversion or change of control for resolving dependencies. It is a process through which OBJECTS define their dependencies. Transferring the task of creating objects to someone ELSE and using the dependency is CALLED dependency injection. It can be done in 2 ways: constructor-based DI and setter-based DI.

279.

Explain the difference between IOC and Di?

Answer»
 IOCDI
1.Program delegates SOMEONE else to drive the FLOWProgram flow CONTROLLED by framework or runtime
2.General parent termSubset of IOC
280.

Explain the benefits of Spring framework?

Answer»

Following are the benefits of using Spring Framework:

  • Enables developers to use POJO to build enterprise-class applications
  • Simpler testing processes
  • MVC framework provides good ALTERNATIVE to other FRAMEWORKS, LIKE Struts
  • Convenient API TRANSLATES technology-specific exceptions
  • Lightweight IoC containers
  • Consistent TRANSACTION management interface
281.

What is spring? Explain

Answer»

Spring is ONE of the most POPULAR open source app development frameworks for enterprise-class Java. Spring is lightweight in terms of size. Some of its core features can be used to develop any Java application, and there are in-built EXTENSIONS on top of the Java EE platform for BUILDING web applications. Spring FRAMEWORK is called a one-stop platform for building enterprise-level Java applications.

282.

How many types of ResultSet are there in JDBC?

Answer»

There are THREE TYPES of RESULTSET in JDBC, namely

  • Forward-only
  • Scroll-insensitive
  • Scroll-sensitive
283.

What is Addbatch JDBC?

Answer»
284.

What is two-phase commit in the database?

Answer»

It is a standardized protocol ASSURING the implementation of a database commit in such a situation where the commit operation has to be broken into 2 parts. Saving the changes in the database is CALLED commit whereas, rollback is undoing the changes. In the first phase of the commit, data is written into the data records by the servers needing commit data to the log. In the next step, it begins after getting the successful MESSAGE from the previous phase, and the particular object, i.e., the coordinator, SENDS a signal to each SERVER with the instructions of the commit.

20. What are the steps required to execute a query in JDBC?
285.

What is JDBC connection?

Answer»
286.

Explain the locking system in JDBC & its types?

Answer»

The LOCKS are the preventive SOFTWARE mechanism which the other users cannot USE the DATA resource.

Types of locks are there-
  • Row and KEY locks
  • Page Locks
  • Table locks
  • Database locks
287.

What is connection pooling and why it is used?

Answer»

Connection pooling is a maintained CACHE of DATABASE connections which are kept to be USED for the future use of the database requests arise. It HELPS in improving the performance of the commands to be executed in the database.

288.

Which package is used for JDBC application?

Answer»

PACKAGE Javax.sql is USED for JDBC APPLICATION.

289.

List the common JDBC exceptions ?

Answer»

There are SEVERAL JDBC EXCEPTIONS such as

  • Java.sql.BatchUpdateException
  • java.sql.SQLException
  • java.sql.DataTruncation
  • java.sql.SQLWarning
290.

What is Savepoint in JDBC?

Answer»

It is the point to which the TRANSACTION gets ROLLED back without affecting the preceding work. The method which is used for setting a SAVEPOINT object WITHIN the CURRENT transaction is Connection.setSavepoint().

291.

What is transaction processing in JDBC?

Answer»

In JDBC, CARRYING out of all the sets of actions in ONE go is known as a TRANSACTION. It is an atomic action in which either all are carried out, or none of them is carried out. Java Transaction API

292.

What is the Execute method in Java?

Answer»

The method is used for EXECUTING a query. It returns true if the ResultSet object is the query return. It returns ONE ResultSet object.

Example

Int m = st.executeUpdate(SQL);

If (m==1)

System.out.println (“inserted successfully: “+sql);

Else

System.out.println (“insertion failed”);

293.

Explain the difference between resultset and rowset in JDBC

Answer»
294.

What is a rollback in JDBC?

Answer»

It is used for rolling BACK the transactions or committing them explicitly. It is LIKE UNDOING the changes. An action can be rolled back to the same SAVEPOINT more than once.

295.

What is the use of the statement in JDBC?

Answer»

The two statements in JDBC, such as PreparedStatement, and CallableStatement are USED for DEFINING the properties and the METHODS for letting the user send PL/SQL or SQL commands. Also, RECEIVING the data from the database and determining the methods for bridging the data type differences become comfortable with the statement interfaces.

296.

Explain the Steps in writing a Java program using JDBC?

Answer»
297.

What are the different types of JDBC drivers?

Answer»

The FOLLOWING are the TYPES of JDBC drivers-

  • JDBC-ODBC BRIDGE DRIVER
  • Native-API Driver
  • All Java+ Middleware translation driver
  • Pure Java Driver
298.

Explain the necessary steps to connect to the database in Java?

Answer»
  • IMPORT JDBC packages and then load in any of the FOLLOWING WAYS- Class.forName(), DriverManager.registerDriver(). Then register JDBC driver
  • Open the connection to the database Connection con= DriverManager.getConnection (url, user, password)
  • To PERFORM a query, create a statement object Statement st= con.createStatement ();
  • Implement the statement object and then RETURN the query resultset. After that process it.
  • Close the resultset, statement objects, and the connection Con.close();
299.

Why do we use JDBC in Java?

Answer»

This JAVA SE TECHNOLOGY is used for building connecting java application with the database. It gets automatically installed with JDK software and used for the communication of Java application to the database in the platform and database INDEPENDENT MANNER.

300.

Explain some new features available in JDBC 4.0?

Answer»
  • Exception handling- In the new features of JDBC 4.0, there is an addition of the abilities to recover from the exceptions by including support for the chained exceptions. These are used for the retrieval of the chained exceptions.
  • Driver and connection management- DriverManager with the appropriate DataSource object GIVES way to the connection retrieval and allows the portability and transparency of the data source INSTANCE. There are no requirements of bringing any changes in the APPLICATION code for building a connection to the different DATABASE instance.
  • Data type support- Additions of some new data types and the rise in the support for others is another UNIQUE feature of JDBC 4.0. Also, new features of the interface, SQLML are added.
  • Changes in API- Important and most required API changes have been done here in JDBC 4.0- Array, Connection and PooledConnection, DatabaseMetaData, Wrapper, Statement, PreparerdStatement, and CallableStatement, etc.