Question 1: Person and Address Injection:
=========================================
You are tasked with developing a Spring Core application where a Person object has
an Address object injected using setter-based dependency injection.
Requirements:
--------------
Address Class:
--------------
Attributes:
-----------
.String city
.String country
.Setter methods for both fields.
Person Class:
--------------
Attributes:
------------
.String name
.Address address
.Setter methods for both fields.
.A method displayInfo() that prints the person's name and address (city, country).
Note:
------
Use an XML file to:
-------------------
.Define both Person and Address beans.
.Inject the Address bean into the Person bean via setter.
Main Class:
------------
Load Spring context, get Person bean, call displayInfo().
Question 2: Library and Books Injection:
=========================================
You are tasked with developing a Spring Core application where a Library contains a
list of Book objects injected using setter-based dependency injection.
Requirements:
Book Class:
Attributes:
String title
String author
Setter methods for both.
Library Class:
Attributes:
List<Book> books
Setter method to inject the list of books.
Method displayBooks() to print all book titles and authors.
Note:
Use an XML file to:
Create multiple Book beans.
Inject them as a list into the Library bean using <list>.
Main Class:
Load Spring context, retrieve Library bean, and call displayBooks().
Question 3: Company and Multiple Departments Injection:
=======================================================
You are tasked with developing a Spring Core application where a Company has
multiple Department objects injected via setter-based dependency injection.
Requirements:
Department Class:
Attributes:
String deptName
int deptId
Setter methods.
Company Class:
Attributes:
List<Department> departments
Setter method.
A showDepartments() method that prints all department names and IDs.
Note:
Define Department beans and inject them into the Company bean using list collection
in XML.
Main Class:
Load context, get Company bean, and call showDepartments().