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 2 of 8

Q11.
The bean instance is mentioned by the factory-method attribute, while the factory method is signified by the factory-bean attribute?
Discuss
Answer: (b).False
Q12.
One factory class can also hold more than one factory method.
Discuss
Answer: (a).True
Q13.
What will be the output of following code?
public class CreatePro 
{
     String ProductId;
     public CreatePro(String ProductId)	
     this.ProductId = ProductId;
}
 
public static Product creation_Product(String productId) 
{	
     System.out.println("Bean Created");
     if ("aaa".equals(productId)) 
     {
        return new Battery("AAA", 2.5);
     } 
     else if ("cdrw".equals(productId)) 
     {
	return new Disc("CD-RW", 1.5);
     }
 
}
 
  <beans ...>
	<bean id="aaa" class="CreatePro"
	factory-method="createProduct">
	<constructor-arg value="aaa" />
	</bean>
	<bean id="cdrw" class="CreatePro"
	factory-method="createProduct">
	<constructor-arg value="cdrw" />
	</bean>
  </beans>
  slight change in XML file:-
 
<bean id="aaa" factory-bean="productCreator"
factory-method="createProduct">
<constructor-arg value="aaa" />
</bean>
<bean id="cdrw" factory-bean="productCreator"
factory-method="createProduct">
<constructor-arg value="cdrw" />
</bean>
Discuss
Answer: (c).New Product will be created
Q14.
Instance Factory method main purpose is to encapsulate the object-creation process in a method of another object instance.
Discuss
Answer: (a).True
Q15.
Which Attribute is used to specify the bean declared?
Discuss
Answer: (a).factory-bean
Q16.
Comment on the following pieces of code.
A)

      public abstract class Product {
	public static final Product AAA = new Battery("AAA", 2.5);
	public static final Product CDRW = new Disc("CD-RW", 1.5);
	...
      }
      <beans ...>
	<bean id="aaa" class="org.springframework.beans.factory.config.
	FieldRetrievingFactoryBean">
	<property name="staticField">
	<value>com.shop.Product.AAA</value>
	</property>
	</bean>
	<bean id="cdrw" class="org.springframework.beans.factory.config.
	FieldRetrievingFactoryBean">
	<property> name="staticField"
	valuecom.shop.Product.CDRW/value
	</property>
	</bean>
     </beans>
 
   B) Product aaa = com.shop.Product.AAA;
      Product cdrw = com.shop.Product.CDRW;
Discuss
Answer: (a).A and B are equivalent
Discuss
Answer: (c).All of the mentionedAll of the mentioned
Q18.
Declaring Beans using:-Ways to declare bean from a static field?Declaring a bean from a static field requires a built-in factory bean FieldRetrievingFactoryBean and fully qualified field name or instance field is specified in the list property.As an alternative to specifying the field name in the staticField property explicitly, you can set it as the bean name of FieldRetrievingFactoryBean.
Discuss
Answer: (b).All of the mentionedAll of the mentionedFalseTrue
Discuss
Answer: (c).All of the mentioned
Q20.
Declaring Beans using:-Ways to declare bean from a static field?Declaring a bean from a static field requires a built-in factory bean FieldRetrievingFactoryBean and fully qualified field name or instance field is specified in the list property.
Discuss
Answer: (b).All of the mentionedAll of the mentionedFalse
Page 2 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!