0% found this document useful (0 votes)
26 views2 pages

Spring Core Day 3 XML Based Configuration - 139447

Uploaded by

abhishektomarcpr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Spring Core Day 3 XML Based Configuration - 139447

Uploaded by

abhishektomarcpr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q1/- Explain about the life-cycle of a Spring Bean.

Q2/- How many scopes are there for a Spring Bean, which is the default scope for a Spring
Bean? Explain with an example.

Q3/- What is the difference between setter injection and constructor injection?

Q4/- What is auto wiring in Spring, how many types of Auto wiring are there in spring,
explain with an example.

Q5/- Consider following class :

class Employee{

empId;
empName;
address;
salary;

//use constructor injection to inject the above fields.


//override the toString method with all the above fields

class Department{

deptId;
deptName;
location;

//use constructor injection to inject the above fields.


//override the toString method with all the above fields

class Demo {

private Map<Department, Employee> theMap;

//use setter injection to inject theMap;

public void myInit(){


System.out.println(“inside myInit method”);
}

public void cleanUp(){


System.out.println(“inside cleanUp method”);
}

Public void showDetails(){


System.out.println(“inside showDetails of Demo class”);
//print all the details of all the employees department-wise.
}

Note:
● Configure 3 department objects (Sales, Marketing, Accounts), and in each
department associate one Employee object.

● Make myInit and init-method and cleanUp method as destroy method, both
should be called.
● Initialize the Demo object lazily.
● From the main method of the Demo class call the showDetails() method by pulling
the object from the Spring Container.

You might also like