πŸ§ͺ Spring MCQ Quiz Hub

Spring Mcq Set 1

Choose a topic to test your knowledge and improve your Spring skills

Beans can be created by which of the following properties?





βœ… Correct Answer: 4

Which attribute is used to specify class name of the bean?





βœ… Correct Answer: 3

Which of the following method can be used to used to instantiate a method?





βœ… Correct Answer: 1

Which attribute is used to specify static factory-method?





βœ… Correct Answer: 1

Purpose of Static Factory Method?





βœ… Correct Answer: 1

Exception thrown by factory method?





βœ… Correct Answer: 1

What will be the output? Snippet of 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>





βœ… Correct Answer: 1

Beans can be created by which of the following properties?





βœ… Correct Answer: 3

Bean’s naming convention:- starts with lowercase, camelcase from then on.?





βœ… Correct Answer: 1

A bean can have more than one name using multiple id attributes?





βœ… Correct Answer: 1

The bean instance is mentioned by the factory-method attribute, while the factory method is signified by the factory-bean attribute?





βœ… Correct Answer: 2

One factory class can also hold more than one factory method True/False?





βœ… Correct Answer: 1

Instance Factory method main purpose is to encapsulate the object-creation process in a method of another object instance.





βœ… Correct Answer: 1

Which Attribute is used to specify the bean declared?





βœ… Correct Answer: 1

Declaring Beans using:-





βœ… Correct Answer: 3

Ways to declare bean from a static field?





βœ… Correct Answer: 3

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.





βœ… Correct Answer: 2

. 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;





βœ… Correct Answer: 1

Is this bean configuration metadata correct? <beans ...> bean id="com.shop.Product.AAA" class="org.springframework.beans.factory.config. FieldRetrievingFactoryBean" / bean id="com.shop.Product.CDRW" class="org.springframework.beans.factory.config. FieldRetrievingFactoryBean" / </beans>





βœ… Correct Answer: 1

Which tag is also allowed by static field?





βœ… Correct Answer: 1

Is this bean configuration correct? <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util/spring-util-3.0.xsd" util:constant id="aaa" static-field="com.shop.Product.AAA" /> util:constant id="cdrw" static-field="com.shop.Product.CDRW" /> </beans>





βœ… Correct Answer: 2

Declaring bean form object properties can be done using:-





βœ… Correct Answer: 1

Inner Bean can be retrieved by it’s name.





βœ… Correct Answer: 2

PropertyPathFactoryBean declares a bean from an:-





βœ… Correct Answer: 3

The propertyPath property of PropertyPathFactoryBean can accept only a single property name.





βœ… Correct Answer: 2

Alternate way of PropertyPathFactoryBean to declare a bean.





βœ… Correct Answer: 1

We can combine target Object and propertyPath properties as bean name/id of PropertyPathFactoryBean.





βœ… Correct Answer: 1

The Spring Expression Language can be accessed by:-





βœ… Correct Answer: 3

A bean can be requested by:-





βœ… Correct Answer: 3

Which attribute is used to set the scope of the bean?





βœ… Correct Answer: 2

Which one is the default scope of the beans?





βœ… Correct Answer: 4

Which scope creates a new bean instance each time when requested?





βœ… Correct Answer: 2

Which of the following are considered valid beans?





βœ… Correct Answer: 3

In above question if scope of shoppingCart named bean is prototype, then what will be the output? What will be the output?





βœ… Correct Answer: 2

Which interface is used to perform initialization of beans?





βœ… Correct Answer: 1

Which interface is used to perform destruction of beans?





βœ… Correct Answer: 2

Alternate way of initialization method is:-





βœ… Correct Answer: 1

Alternate way of destruction method is:-





βœ… Correct Answer: 3

Which annotation is used as a substitute of initialization method?





βœ… Correct Answer: 1

Which annotation is used as a substitute of destroy method?





βœ… Correct Answer: 2

Which configuration can be used for Dependency Injection?





βœ… Correct Answer: 4

Method used to process bean before initialization callback





βœ… Correct Answer: 3

Method used to process bean after initialization callback





βœ… Correct Answer: 3

Which method is used to gracefully shutdown all the bean processes after closing the spring container?





βœ… Correct Answer: 1

Which method is used to register BeanPostProcessor?





βœ… Correct Answer: 1

Which Interface for bean Post Processor is used to distinguish between checked beans





βœ… Correct Answer: 1

Which method of bean post processors is used to check path existence





βœ… Correct Answer: 1

PathCheckingBeanPostProcessor will not work properly in case of:-





βœ… Correct Answer: 3

Which bean factory post processor externalizes part of the bean configurations into a properties file





βœ… Correct Answer: 1

Which interface defines methods for resolving text messages





βœ… Correct Answer: 1