Java

Spring Framework Practice Problems and Their Solutions

This article presents a few Spring Framework Practice Problems and Their Solutions.

A Brief Tutorial on Spring Framework

  1. A Java application has a Model class ‘Art’. Further, this class has three attributes – art_id, art_title, and artist_name. You are required to create a Spring XML configuration file to create a bean entry for the Art object. This object must have some property values. Also, develop a program to display the details of the Art objects.
  2. Create a class called MyBlogs containing a single data member named blogname. Initialise this variable with a value ‘programmingempire.com’. Another method should instantiate this class and display the value of blogname.
  3. Develop a Java application that contains an Abstract class Shape with an abstract method findArea(). Also, define its three subclasses – Circle, Rectangle, and Triangle. Another class called ShapeArea should contain the main() method. Create the objects of these classes on the basis of dependency injection. Finally, call the appropriate findArea() method.
  4. Modify the program in Exercise 2. Initialise the data member blogname with null. Instead, create a parameterized constructor to initialise it.
  5. After that, instantiate this class using the Inversion control.
  6. Further modify the above program to demonstrate Setter Injection.
  7. Create a class Exam with attributes exam_id, exam_title, and exam_score. Further, create another class StudentResult with attributes sname, semail, and exam (object of the Exam class). After that, create two instances of the StudentResult class. First one is for the student who takes the exam of ‘Python Programming’. While the other one takes the exam pf “Spring Boot’. Display the details of both students.
  8. Create a class Author and another class Book. The Book has one of the data members as author which is an object of the Author class. After that create several instances of the Book class. Further, display the details of all books. Also, display the books by each author. Develop a Spring application for this problem.

Spring MVC Exercise.


Further Reading

Java Practice Exercise

programmingempire

Princites

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *