adplus-dvertising

Welcome to the Introduction to Spring MCQs Page

Dive deep into the fascinating world of Introduction to Spring with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Introduction to Spring, a crucial aspect of Java Spring Framework. In this section, you will encounter a diverse range of MCQs that cover various aspects of Introduction to Spring, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Spring Framework.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Introduction to Spring. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Spring Framework.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Introduction to Spring. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Introduction to Spring MCQs | Page 4 of 8

Explore more Topics under Java Spring Framework

Discuss
Answer: (c).all of the mentioned
Q32.
Which attribute is used to set the scope of the bean?
Discuss
Answer: (b).scope
Q33.
Which one is the default scope of the beans?
Discuss
Answer: (d).Singleton
Q34.
Which scope creates a new bean instance each time when requested?
Discuss
Answer: (b).Prototype
Q35.
Session Creates a single bean instance per HTTP request, only valid in the context of a web application?
Discuss
Answer: (b).False
Q36.
Which of the following are considered valid beans?
Discuss
Answer: (c).All of the mentioned
Q37.
What will be the output?
public class ShoppingCart 
{
    private List<Product> items = new ArrayList<Product>();
    public void addItem(Product item) 
    {
       items.add(item);
    }
    public List<Product> getItems() 
    {
       return items;
    }
}
 
   <beans ...>
 <bean id="aaa" class="com.shop.Battery">
 <property name="name" value="AAA" />
 <property name="price" value="2.5" />
 </bean>
 <bean id="cdrw" class="com.shop.Disc">
 <property name="name" value="CD-RW" />
 <property name="price" value="1.5" />
 </bean>
 <bean id="dvdrw" class="com.shop.Disc">
 <property name="name" value="DVD-RW" />
 <property name="price" value="3.0" />
 </bean>
 <bean id="shoppingCart" class="com.shop.ShoppingCart" />
   </beans>
 
   import org.springframework.context.ApplicationContext;
   import org.springframework.context.support.ClassPathXmlApplicationContext;
   public class Main 
   {
 public static void main(String[] args) {
 ApplicationContext context =
 new ClassPathXmlApplicationContext("beans.xml");
 Product aaa = (Product) context.getBean("aaa");
 Product cdrw = (Product) context.getBean("cdrw");
 Product dvdrw = (Product) context.getBean("dvdrw");
 ShoppingCart cart1 = (ShoppingCart) context.getBean("shoppingCart");
 cart1.addItem(aaa);
 cart1.addItem(cdrw);
 System.out.println("Shopping cart 1 contains " + cart1.getItems());
 ShoppingCart cart2 = (ShoppingCart) context.getBean("shoppingCart");
 cart2.addItem(dvdrw);
 System.out.println("Shopping cart 2 contains " + cart2.getItems());
 }
   }
  
Discuss
Answer: (a).Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
Shopping cart 2 contains (AAA 2.5, CD-RW 1.5, DVD-RW 3.0)
Q38.
Which interface is used to perform initialization of beans?
Discuss
Answer: (a).InitializingBean
Q39.
Which interface is used to perform destruction of beans?
Discuss
Answer: (b).Disposablebean
Discuss
Answer: (a).init-method attribute
Page 4 of 8

Suggested Topics

Are you eager to expand your knowledge beyond Java Spring Framework? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!