File Name: interview questions and answers on spring and hibernate in java .zip
Spring is an open source development framework for enterprise Java. The main features of spring may be used for developing applications of Java. Also, extensions for making web applications on top of JavaEE platform can be done.
Dear readers, these Spring Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Spring.
As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer:. Spring is an open source development framework for enterprise Java.
The core features of the Spring Framework can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring framework targets to make J2EE development easier to use and promote good programming practice by enabling a POJO-based programming model.
The basic version of spring framework is around 2MB. The objects give their dependencies instead of creating or looking for dependent objects. Spring configuration file is an XML file. This file contains the classes information and describes how these classes are configured and introduced to each other.
Inversion of Control IoC is a general concept, and it can be expressed in many different ways and Dependency Injection is merely one concrete example of Inversion of Control. This concept says that you do not create your objects but describe how they should be created.
You don't directly connect your components and services together in code but describe which services are needed by which components in a configuration file. A container the IOC container is then responsible for hooking it all up. Since you can mix both, Constructor- and Setter-based DI, it is a good rule of thumb to use constructor arguments for mandatory dependencies and setters for optional dependencies.
Note that the use of a Required annotation on a setter can be used to make setters required dependencies. It makes your application easy to test as it doesn't require any singletons or JNDI lookup mechanisms in your unit test cases. Aspect-oriented programming, or AOP, is a programming technique that allows programmers to modularize crosscutting concerns, or behavior that cuts across the typical divisions of responsibility, such as logging and transaction management.
The core construct of AOP is the aspect, which encapsulates behaviors affecting multiple classes into reusable modules. The Spring IoC creates the objects, wire them together, configure them, and manage their complete lifecycle from creation till destruction. The Spring container uses dependency injection DI to manage the components that make up an application. The BeanFactory is usually preferred where the resources are limited like mobile devices or applet based applications.
This container reads the configuration metadata from an XML file and uses it to create a fully configured system or application.
Here you need to provide the full path of the XML bean configuration file to the constructor. Application contexts provide a means for resolving text messages, including support for i18n of those messages. Certain operations on the container or beans in the container, which have to be handled in a programmatic fashion with a bean factory, can be handled declaratively in an application context. The application context implements MessageSource, an interface used to obtain localized messages, with the actual implementation being pluggable.
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. For example, to force Spring to produce a new bean instance each time one is needed, you should declare the bean's scope attribute to be prototype. Similar way if you want Spring to return the same bean instance each time one is needed, you should declare the bean's scope attribute to be singleton.
The Spring Framework supports following five scopes, three of which are available only if you use a web-aware ApplicationContext. Only valid in the context of a web-aware Spring ApplicationContext. If the bean has init method declaration, the specified initialization method is called. An inner bean definition does not require a defined id or name; the container ignores these values.
It also ignores the scope flag. Inner beans are always anonymous and they are always scoped as prototypes. The Spring container is able to autowire relationships between collaborating beans. You have nothing to do special for this wiring. This is what you already have seen in Dependency Injection chapter.
Spring container looks at the properties of the beans on which autowire attribute is set to byName in the XML configuration file. It then tries to match and wire its properties with the beans defined by the same names in the configuration file. Spring container looks at the properties of the beans on which autowire attribute is set to byType in the XML configuration file. It then tries to match and wire a property if its type matches with exactly one of the beans name in configuration file.
If more than one such beans exist, a fatal exception is thrown. If there is not exactly one bean of the constructor argument type in the container, a fatal error is raised. An alternative to XML setups is provided by annotation-based configuration which relies on the bytecode metadata for wiring up components instead of angle-bracket declarations. Instead of using XML to describe a bean wiring, the developer moves the configuration into the component class itself by using annotations on the relevant class, method, or field declaration.
Annotation wiring is not turned on in the Spring container by default. This annotation simply indicates that the affected bean property must be populated at configuration time, through an explicit property value in a bean definition or through autowiring.
The container throws BeanInitializationException if the affected bean property has not been populated. This annotation provides more fine-grained control over where and how autowiring should be accomplished.
There may be a situation when you create more than one bean of the same type and want to wire only one of them with a property, in such case you can use Qualifier annotation along with Autowired to remove the confusion by specifying which exact bean will be wired.
The Resource annotation takes a 'name' attribute which will be interpreted as the bean name to be injected. You can say, it follows by-name autowiring semantics.
Java based configuration option enables you to write most of your Spring configuration without XML but with the help of few Java-based annotations. For example: Annotation Configuration indicates that the class can be used by the Spring IoC container as a source of bean definitions. The Bean annotation tells Spring that a method annotated with Bean will return an object that should be registered as a bean in the Spring application context.
Event handling in the ApplicationContext is provided through the ApplicationEvent class and ApplicationListener interface. So if a bean implements the ApplicationListener , then every time an ApplicationEvent gets published to the ApplicationContext, that bean is notified. This can also be raised using the refresh method on the ConfigurableApplicationContext interface.
You can do required housekeep work after receiving this event. A closed context reaches its end of life; it cannot be refreshed or restarted. A module which has a set of APIs providing cross-cutting requirements. For example, a logging module would be called AOP aspect for logging. An application can have any number of aspects depending on the requirement. In Spring AOP, aspects are implemented using regular classes the schema-based approach or regular classes annotated with the Aspect annotation AspectJ style.
Concern may be defined as a functionality we want to implement. Issues in which we are interested define our concerns. This represents a point in your application where you can plug-in AOP aspect. You can also say, it is the actual place in the application where an action will be taken using Spring AOP framework.
This is the actual action to be taken either before or after the method execution. This is actual piece of code that is invoked during program execution by Spring AOP framework. This is a set of one or more joinpoints where an advice should be executed. You can specify pointcuts using expressions or patterns as we will see in our AOP examples.
The object being advised by one or more aspects, this object will always be a proxy object. Also referred to as the advised object. Weaving is the process of linking aspects with other application types or objects to create an advised object. AspectJ refers to a style of declaring aspects as regular Java classes annotated with Java 5 annotations. JDBC can be used more efficiently with the help of a template class provided by spring framework called as JdbcTemplate.
With use of Spring JDBC framework the burden of resource management and error handling is reduced a lot. So it leaves developers to write the statements and queries to get the data to and from the database.
JdbcTemplate provides many convenience methods for doing things such as converting database data into primitives or objects, executing prepared and callable statements, and providing custom database error handling. That gives you extreme flexibility, but it is difficult to maintain.
You only use annotations or XML based configuration to manage the transactions. Declarative transaction management is preferable over programmatic transaction management though it is less flexible than programmatic transaction management, which allows you to control transactions through your code. The Spring web MVC framework provides model-view-controller architecture and ready components that can be used to develop flexible and loosely coupled web applications.
The MVC pattern results in separating the different aspects of the application input logic, business logic, and UI logic , while providing a loose coupling between these elements. The WebApplicationContext is an extension of the plain ApplicationContext that has some extra features necessary for web applications. It differs from a normal ApplicationContext in that it is capable of resolving themes, and that it knows which servlet it is associated with. Spring's MVC is very versatile and flexible based on interfaces but Struts forces Actions and Form object into concrete inheritance.
Spring provides both interceptors and controllers, thus helps to factor out common behavior to the handling of many requests. Web tier of Spring MVC is easy to test than Struts web tier, because of the avoidance of forced concrete inheritance and explicit dependence of controllers on the dispatcher servlet.
Struts force your Controllers to extend a Struts class but Spring doesn't, there are many convenience Controller implementations that you can choose to extend. With Struts, validation is usually performed implemented in the validate method of an ActionForm.
In SpringMVC, validators are business objects that are NOT dependent on the Servlet API which makes these validators to be reused in your business logic before persisting a domain object to a database. Controllers provide access to the application behavior that you typically define through a service interface.
Controllers interpret user input and transform it into a model that is represented to the user by the view. Spring implements a controller in a very abstract way, which enables you to create a wide variety of controllers. The Controller annotation indicates that a particular class serves the role of a controller.
Ever since its release back in October of , Spring Framework has succeeded in becoming a top application framework for Java developers. In fact, it secures a place among the leading backend web development frameworks. Hence, opting for a career in Spring Framework is very lucrative. Spring Framework has a wide array of concepts that one needs to have a working understanding in order to stay ahead in the game. Answer: Spring Framework has about 20 modules. Each of them is classified into one of the following layers:. Answer: A typical Spring application can be subdivided into the following components:.
It is the execution of an aspect. Advice is like making your application learn a new trick. They are usually introduced at joinpoints.
I have posted a lot of Spring Tutorials recently. This post will help you get through Spring interview Questions explaining the core concepts in detail. Spring Framework is one of the most popular Java EE frameworks for web applications. If you are good in Spring Framework, the chances of getting selected get high.
What is Spring? Answer: Spring is an open source development framework for Enterprise Java. The core features of the Spring Framework can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring framework targets to make Java EE development easier to use and promote good programming practice by enabling a POJO-based programming model. What do you mean by Aspect? Answer: Aspect is modularization of concern which cuts across multiple objects.
Subscribe to my youtube channel for daily useful videos updates. Are you aware of Daemon Thread in Java? The test suite, that I am talking about is basically a collection of test cases. Here we are going to present a list of most asked Java 8 interview questions that will help you.
Java Spring Interview Questions, Programs and Examples to help you ace your CHAPTER Spring Interview Questions PDF tools support such as Hibernate carlislefamilyconnection.organswers.
Он козырьком поднес руку к глазам и стал разглядывать шпили над внушительным фасадом. - Смотрите внимательно, - предупредил Смит.
Когда он проходил мимо лифта, дверцы открылись. В кабине стоял какой-то мужчина. Беккер успел заметить лишь очки в железной оправе. Мужчина поднес к носу платок.
Провода от принтера лежали .
Быть может, вы оставите… - Всего на одну минуту. Она в столовой. Консьерж снова покачал головой: - Ресторан закрылся полчаса. Полагаю, Росио и ее гость ушли на вечернюю прогулку. Если вы оставите для нее записку, она получит ее прямо с утра.
Коммандер. Стратмор даже не пошевелился.
- Стратмор хмыкнул, раздумывая, как поступить, потом, по-видимому, также решил не раскачивать лодку и произнес: - Мисс Флетчер, можно поговорить с вами минутку. За дверью. - Да, конечно… сэр. - Сьюзан не знала, как. Бросила взгляд на монитор, потом посмотрела на Грега Хейла.
Люди часто нарушают правила, когда сталкиваются с подобной настойчивостью.
Dear readers, these Spring Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Spring.Mariette C. 10.05.2021 at 14:41
How can we integrate Spring and Hibernate using HibernateDaoSupport? concerning the Spring Framework, that you may be asked to answer There is no need to worry for your next interview test, because Java Code Geeks are here.Carrie W. 12.05.2021 at 19:57
Spring is largely a redundancy.Isobel W. 13.05.2021 at 00:03
There are a lot of opportunities from many reputed companies in the world.Witomesma 14.05.2021 at 14:41
Top 53 spring interview questions and answers pdf in Spring framework targets to make Java EE development easier to use and promote good Integration with Hibernate, JDO, and iBATIS: Spring provides best Integration services.