Questions
- What is loose coupling?
- What is a Dependency?
- What is IOC (Inversion of Control)?
- What is Dependency Injection?
- Can you give few examples of Dependency Injection?
- What is Auto Wiring?
- What are the important roles of an IOC Container?
- What are Bean Factory and Application Context?
- Can you compare Bean Factory with Application Context?
- How do you create an application context with Spring?
- -->IOC Container
- Find Beans
- Wire Dependencies
- Manage Lifecycle of the Bean
- -->Application Context
- Bean Factory++
- Spring’s AOP features
- I18n capabilities
- WebApplicationContext for web applications etc.
- How does Spring know where to search for Components or Beans?
- What is a component scan?
- How do you define a component scan in XML and Java Configurations?
- How is it done with Spring Boot?
- What does @Component signify?
- What does @Autowired signify?
- What’s the difference Between @Controller,@Component, @Repository, and @Service Annotations in Spring?
- Answer - @Component - Spring should manage the bean.
- @Autowired - Spring should find the matching bean and wire the dependency in.
- @Component - Generic Component
- @Repository - encapsulating storage, retrieval, and search behavior typically from a relational database.
- @Service - Business Service Facade.
- @Controller - Controller in MVC pattern.
- What is the default scope of a bean?
- A - Spring framework does not do anything under the hood concerning the multi-threaded behavior of a singleton bean. It is the developer's
- responsibility to deal with concurrency issue and thread safety of the singleton bean. While practically, most spring beans have no mutable
- state, and as such are trivially thread safe.
- Are Spring beans thread safe?
- What are the other scopes available?
- How is Spring’s singleton bean different from Gang of Four Singleton Pattern?
- A - The singleton scope is the default scope in Spring.
- The Gang of Four defines Singleton as having one and only one instance per ClassLoader.
- However, Spring singleton is defined as one instance of bean definition per container.
- singleton - One instance per Spring Context
- prototype - New bean whenever requested
- request - One bean per HTTP request. Web-aware
- Spring ApplicationContext.
- session - One bean per HTTP session. Web-aware
- Spring ApplicationContext
- What are some of the important Spring annotations you have used?
- Annotations
- @Component, @Service, @Repository, @Controller
- @Autowired
- @Primary
- @Qualifier
- @Configuration
- What do you think about Spring Framework? Why is Spring Popular? Can you give a big picture of the Spring Framework?
- Answer :
- Architecture - Flexible & No Restrictions
- Design - Loosely Coupled
- Code - Easy Unit Testing
- Features - Dependency Injection, IOC
- Container(Bean Factory & Application Context), Auto
- wiring, Component Scan
- Spring Modules
- Spring Projects
- Why Spring Boot?
- Spring based applications have a lot of configuration.
- When we use Spring MVC, we need to configure component scan, dispatcher servlet, a view resolver, web jars(for delivering static content) among other things.
- World is moving towards Microservices.
- We do not have a lot of time to set up 100 microservices.
- Spring Boot Goals
- Quick Start to Spring
- Be opinionated
- Non functional features
- No code generation
- Spring Projects
- Spring Boot - refer the link for complete info https://learn2100.blogspot.com/2018/07/spring-boot.html
- Spring Cloud
- Spring Data
- Spring Integration
- Spring Batch
- Spring Security
- Spring HATEOAS
- Spring Web Services
- Spring Session
References :
https://howtodoinjava.com/spring/spring-core/spring-beans-autowiring-concepts/
Ioc vs DI
https://howtodoinjava.com/spring/spring-core/inversion-of-control-ioc-and-dependency-injection-di-patterns-in-spring-framework-and-related-interview-questions/
No comments:
Post a Comment