Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Q1.) What is a frameWork?

A1.)1. a frameWork is a collection of jar and war files.


2. it consists of reUsable components and libraries.
3. it is collection of classes and interfaces
4. it provides structure for writing programs

Q2.) Types of frameWork ?


A2.)1. Invasive FrameWork
a frameWork that forces you to implement or extend
2. Non-Invasive FrameWork
a frameWork that do-not force to implement or extend
eg:- struts , hibernate , spring

Q3.) What is IOC & IOC Lifecycle ?


A3.) it is a design pattern that allows program control to be inverted
or
transfer from traditional in-process control structure to separate service provider .

LifeCycle of IOC

1. Initialization :- IOC container is initialised and configured.


2. Binding :- Components are registered with container & can be specifying interfaces
.
3. Resolution :- Dependencies of the components are resolved and the appropriate
instance is created
4. Invocation :- Container invokes specific methods of the components.
5. Destruction :- Component destroyed & restore released

Q4.) What is SingleTon class and Rules to create class ?


A4.) A class that is limited to one instance of itself
this means only one object of the class can be created
Most common use of this class is to provide global access to objects

RULES of Singleton class

1. class must be declared Private


2. private constructor
3. static variables of same type
4. public static method must return instance of class

Q5.) What is dependency Injection and Types


A5.) a class receives instances of object it depends upon external
source rather than creating them itself .
this allows class to be independent of how the object
it depends on are created & makes code easier to maintain test

Rules of DI
1. Constructor-based Dependency Injection:- in this dependent object is provided
as the parameter in the constructor of class .
it is provided when class is instantiated.

2. Setter-based Dependency Injection :- dependent object is provided in class


through setter methods
this is useful when dependency is optional or when it can be changed even
after class is instantiated

3. Interface-based Dependency Injection :- defined some methods that must be


implemented by dependent objects
this is useful when class needs to be decoupled from dependent objects
allowing it into different implementations of dependent objects

4. Autowiring Dependency Injection :- this injection in spring


framework enables you to inject the object dependency implicitly.
It internally uses setter or constructor injection.

Autowiring can't be used to inject primitive and string values. It works with
reference only.

Q6.) types of bean configuration technique in java

1. XML Based Configuration: This is the most common and popular way of
configuring the Spring beans. The beans are configured using the
XML file, which contains all the bean definitions.

2. Annotation Based Configuration: This type of configuration allows you to


create beans using annotations. You don’t need to create an XML file for the
beans.

3. Java Based Configuration: This type of configuration uses pure Java


classes to configure the beans. The beans are configured using the
@Bean annotation.

Q7.) What is Annotation and use of annotation?


A7.) a form of metaData , A way to provide additional information about a program construct
without changing the program itself it can be used to provide information about class,
methods or field specifying code generation or compilation instruction or providing external
metadata from XML.
it allows developers to add custom information to their code without modifying the code itself
, making it easier to keep track of important information .
this is useful when working on large code base or when trying to keep track of changes
overtime .

Q8.) What is Auto-Wiring?


A8.) it enables frameWork to inject dependency into beans automatically , without explicit
configuration.
it allows beans to be linked together without having explicitly specify their relationship in
configuration file .
it also eliminates the need to specify bean names (manually) in configuration file.

Q9.) What is Java Qualifier & Use of Qualifier ?


A9.) it is used to provide additional information about a variables , methods or class .
it is used to add a level of type safety to code .
@Qualifier can be used to indicate which classes should be used when resolving
dependency injection , to denote which method should be used when overriding & to provide
additional metadata about a method or classes .
@Qualifier can also be used to indicate which parameter should be used in constructor or
method.

Q10.) Scope & bean Scope modes ?


A10.)
1. Singleton: The singleton scope is the default scope used in the Spring framework.
It creates a single instance of the bean and all requests for that bean use the
same instance.

2. Prototype: The prototype scope creates a new instance of the bean every time a
request is made.

3. Request: The request scope creates a new instance of the bean for each HTTP
request.

4. Session: The session scope creates a new instance of the bean for each HTTP
session.

5. Global Session: The global session scope is similar to the session scope, except
it is shared across different servlet contexts.

Q11.) StereoType annotations & use ?


A11.) it is used to define & classify type of classes , fields & methods
it can be used to define / improve code readability & maintainability & to
ensure that code elements are used properly.
it can be used to apply common behaviour such as applying security or
logging ,across multiple elements

Q12.) DataType annotation & use ?


A12.) it is used to specify the type of date that variable is storing .
This helps prevent errors by ensuring the correct type of data is used when
manipulating values .

Q13.) @ComponentScan:-it is used to detect & register components /beans as managed by


Spring frameWork .
it is used to detect classes annotated with @Component , @Service
,@Repository & @Controller
@Configuration:- it is used to define bean definitions in application Context.
it is used to define beans & their properties as part of Spring Framework.

@Value :- it is used to inject literal values into fields ,methods & constructor
it is used to inject literal values in properties

@Required :- it is used to indicate the presence of a dependency for a bean .


it is used to indicate bean property must be configured in bean configuration
file .

@Controller :- it is used on a class that provides web interfaces .


it is used to denote class as controller
class & will
be detected automatically detected by
spring framework
for Component Scan & managed as bean.

@Service :- it is used for class that contains business logic.


it is used to denote that the class is a service class

@Repository :- it is used to indicate that class is repository


it is used to mark class as DataAccess object.
it is used in combination with other annotation such as
service & Component

Q14.) Spring Jdbc /Orm (Implemented methods & Persistent methods) ?


A14.) SpringJDBC:-
1. it is used to simplify managing database transactions
2. it provides templets for Data access & helps to eliminates common error
3. it provides wrapper around existing JDBC code & makes it easier to use

PURPOSE OF Implemented methods & Persistent methods IS TO


automate data access and manipulation

Persistent Methods:

• Create - allows you to create a new entry in the database.


• Retrieve - allows you to retrieve an existing entry from the database.
• Update - allows you to modify an existing entry in the database.
• Delete - allows you to delete an existing entry from the database.
• Save - allows you to save an existing entry in the database.
• Merge - allows you to merge two existing entries in the database.

Implemented methods:
• Data Access Object (DAO) - provides an interface for accessing data from the
database.
• Query Interface - provides a way to create, execute, and manage queries.
• Transaction Management - provides an abstraction layer for managing transactions.
• Object-Relational Mapping (ORM) - provides a way to map Java objects to database
tables.
• Object/Relational (O/R) Metadata Mapping - provides a way to define relationships
between Java objects and database tables.
• Data Access Template - provides a way to easily access and manipulate data in the
database.

SPRING ORM:-
1. it is used to map objects into database tables.
2. it provides easy access to databased methods.
3. these methods are created by using object relational mapping configuration
are used to perform required operations
4. **Additionally , persistent methods can save , retrieve data from database

Q15.) MVC in Spring & SpringBoot?


A15.) 1. Spring MVC is popular web-based framework for webapps
2. it provides model-view-controller architecture & components that help developers
to build web apps easily.

1.Spring Boot is an extension of spring framework that makes easier to create


standalone ,production grade spring based apps
2. it provides embedded webserver , so there is no-need to deploy an
external server
3. it provides auto-configuration for web-apps
4. it provides CLI(Command line interface ) to quickly create & run apps.

Q16.) Spring MVC execution flow ?


A16.)

1. User sends an HTTP Request to a web browser.

2. DispatcherServlet, receives the request and checks the web.xml file to identify the
appropriate Controller.

3. The DispatcherServlet maps the request to the appropriate Controller and calls its handler
methods.

4. The Controller processes the request and generates the Model or view object.

5. The view object is passed to the appropriate View Resolver.

6. The View Resolver identifies the appropriate View Component and prepares the output.
7. The DispatcherServlet passes the output to the web browser.

Q17.) Difference between BeanFactory & Application Context?


A17.) BEANFACTORY
1. it is light weight container
2. it is used for basic dependency injection
3. it creates bean when asked

APPLICATION CONTEXT
1. it is heavy weight container
2. provides more advanced configuration as AOP, iL8n,& validations
3. it creates bean when it is loaded
4. it has the ability to publish events to the beans that are registered as
listeners .

Q18.) What is MAVEN & purpose of maven tool?


A18.) it is used to build , manage & deploy s/w projects
it is used to define project structure, dependency , build & test process
it makes build system easy & uniform system
it automates process of downloading necessary dependencies & compiling
source code into a package that can be deployed.
it supports in generating reports & do communication.

Q19.) What is dependency & purpose ?


A19.) it is relationship b/w 2 software components
where one component relies on the other components to function properly
purpose of dependency is to decouple components in order to make them
modular , re-usable, maintainable.
dependencies also allow better collaboration b/w developers & make it easier
to debug & test applications

Q20.) Describe POM.xml?


A20.) it contains information about project (config details )
it contain default values for most projects as well as the ability to override
these values for specific projects
it contain project dependencies , plugins , goals , & other info needed to build
project
it also contains projects version , developers , licences & other metadata.

You might also like