Spring, Spring Core, Spring IoC Interview Questions
- What is Spring Framework? …
- What are the features of Spring Framework? …
- What is a Spring configuration file? …
- What do you mean by IoC (Inversion of Control) Container? …
- What do you understand by Dependency Injection?
Indeed, What are the important topics in Spring?
Some of the most important features of the Spring framework are as follows:
- IoC container: …
- Data access framework: …
- Spring MVC framework: …
- Transaction management: …
- Spring Web Service: …
- JDBC abstraction layer: …
- Spring TestContext framework:
Then, How Spring is loosely coupled? Spring can make your output generator loosely coupled to the output generator. Minor change in OutputHelper class. Create a Spring bean configuration file and declare all your Java object dependencies here. Now, you just need to change the Spring XML file for a different output generator.
What are different Autowire types? Autowiring Modes
No. | Mode |
---|---|
2) | byName |
3) | byType |
4) | constructor |
5) | autodetect |
In the same way What is MVC in Spring? The Spring Web MVC framework provides Model-View-Controller (MVC) architecture and ready components that can be used to develop flexible and loosely coupled web applications.
What are bean scopes in Spring?
Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext .
What is hibernate in spring boot?
Hibernate is one of the popular implementations of JPA. Hibernate understands the mappings that we add between objects and tables. It ensures that data is stored/retrieved from the database based on the mappings. Hibernate also provides additional features on top of JPA.
What is model in Spring?
Spring Framework provides an Interface called Model(I) to work with the data. It defines a placeholder for model attributes and is primarily designed for adding attributes to the model. It is also used to transfer data between the view and controller of the Spring MVC application.
What is @component annotation in spring boot?
@Component is an annotation that allows Spring to automatically detect our custom beans. In other words, without having to write any explicit code, Spring will: Scan our application for classes annotated with @Component. Instantiate them and inject any specified dependencies into them. Inject them wherever needed.
What is Qualifier annotation in Spring?
The @Qualifier annotation in Spring is used to differentiate a bean among the same type of bean objects. If we have more than one bean of the same type and want to wire only one of them then use the @Qualifier annotation along with @Autowired to specify which exact bean will be wired.
What is @component annotation in Spring boot?
@Component is an annotation that allows Spring to automatically detect our custom beans. In other words, without having to write any explicit code, Spring will: Scan our application for classes annotated with @Component. Instantiate them and inject any specified dependencies into them. Inject them wherever needed.
What is Spring AOP?
What is Spring AOP? Spring AOP enables Aspect-Oriented Programming in spring applications. In AOP, aspects enable the modularization of concerns such as transaction management, logging or security that cut across multiple types and objects (often termed crosscutting concerns).
Which ORM is used in Spring boot?
The Spring Boot Framework integrates well with ORM frameworks like Hibernate, Java Persistence API (JPA), Java Data Objects (JDO) and iBATIS SQL Maps.
What is dependency injection in Spring?
Dependency Injection is a fundamental aspect of the Spring framework, through which the Spring container “injects” objects into other objects or “dependencies”. Simply put, this allows for loose coupling of components and moves the responsibility of managing components onto the container.
What is the difference between JPQL and Hql?
JPQL is the JPA standard entity query language while HQL extends JPQL and adds some Hibernate-specific features. JPQL and HQL are very expressive and resemble SQL. Unlike Criteria API, JPQL and HQL make it easy to predict the underlying SQL query that’s generated by the JPA provider.
What is controller in Spring?
In Spring Boot, the controller class is responsible for processing incoming REST API requests, preparing a model, and returning the view to be rendered as a response. The controller classes in Spring are annotated either by the @Controller or the @RestController annotation.
What is ModelAndView in Spring?
ModelAndView is a holder for both Model and View in the web MVC framework. These two classes are distinct; ModelAndView merely holds both to make it possible for a controller to return both model and view in a single return value. The view is resolved by a ViewResolver object; the model is data stored in a Map .
What is the difference between @component and @bean?
If we see component class like @Controller, @service, @repository will be scan automatically by the spring framework using the component scan. @Bean on the other hand can only be used to explicitly declare a single bean in a configuration class.
What is classpath scanning in Spring?
A Classpath scanning basically means, detecting the classes that need to be managed by the Spring under a specified package. You need to make use of the spring @ComponentScan annotation with the @Configuration for classpath scanning.
What is the difference between @service and @repository?
@Service annotates classes at the service layer. @Repository annotates classes at the persistence layer, which will act as a database repository.
What is @EnableAutoConfiguration in Spring boot?
The @EnableAutoConfiguration annotation enables Spring Boot to auto-configure the application context. Therefore, it automatically creates and registers beans based on both the included jar files in the classpath and the beans defined by us.
Where @autowired can be used?
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.
What is @repository in Spring?
@Repository Annotation is a specialization of @Component annotation which is used to indicate that the class provides the mechanism for storage, retrieval, update, delete and search operation on objects.
What is IoC container in Spring?
Spring IoC Container is the core of Spring Framework. It creates the objects, configures and assembles their dependencies, manages their entire life cycle. The Container uses Dependency Injection(DI) to manage the components that make up the application.
Don’t forget to share this post !