Spring/Spring%20Mcq%20Set%201 Sample Test,Sample questions

Question:
 A bean can be requested by:-

1.getBean method

2. reference from another bean using autowiring, property etc

3.all of the mentioned

4.none of the mentioned

Posted Date:-2022-01-02 16:28:12


Question:
 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>

1. Yes

2.No

3.error

4.None of these

Posted Date:-2022-01-02 16:14:07


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

1.True

2.False

3.None

4.all of the mentioned

Posted Date:-2022-01-02 15:58:37


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

1. True

2. False

3.error

4.None of these

Posted Date:-2022-01-02 16:22:14


Question:
 Which method is used to register BeanPostProcessor?

1.addBeanPostProcessors

2.registerBeanPostProcessors

3.addBeanProcessors

4.none of the mentioned

Posted Date:-2022-01-02 16:40:37


Question:
 Which tag is also allowed by static field?

1.util:constant

2.list

3. set

4.constructor-args

Posted Date:-2022-01-02 16:14:36


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

1.A and B are equivalent

2. A and B provides different functionality

3. Runtime Error in A

4.Exception in B

Posted Date:-2022-01-02 16:13:39


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

1. True

2.False

3.error

4.None of these

Posted Date:-2022-01-02 15:57:49


Question:
Alternate way of destruction method is:-

1. init-method attribute

2.afterPropertiesSet

3.destroy-method attribute

4.none of the mentioned

Posted Date:-2022-01-02 16:35:37


Question:
Alternate way of initialization method is:-

1. init-method attribute

2. afterPropertiesSet

3.destroy-method attribute

4.none of the mentioned

Posted Date:-2022-01-02 16:34:40


Question:
Alternate way of PropertyPathFactoryBean to declare a bean.

1.util:property-path tag

2.util:constant tag

3.None of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:21:45


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

1.True

2. False

3.None

4.all of the mentioned

Posted Date:-2022-01-02 15:56:29


Question:
Beans can be created by which of the following properties?

1. Scope

2. Property

3. Class

4. It’s own constructor

Posted Date:-2022-01-02 15:38:54


Question:
Beans can be created by which of the following properties?

1.Static factory-method

2. Instance Factory-Method

3.All of the mentioned

4.none of the mentioned

Posted Date:-2022-01-02 15:55:19


Question:
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.

1.True

2.False

3.error

4.none of the mentioned

Posted Date:-2022-01-02 16:12:19


Question:
Declaring bean form object properties can be done using:-

1. PropertyPathFactoryBean

2.util:constant

3. None of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:15:52


Question:
Declaring Beans using:-

1.Static field

2. Object Properties

3.All of the mentioned

4.none of the mentioned

Posted Date:-2022-01-02 16:10:44


Question:
Exception thrown by factory method?

1. IllegalArgumentException

2.IndexOutofBoundException

3.ClassPathNotFoundException

4.BeanCreationException

Posted Date:-2022-01-02 15:52:38


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

1.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)

2. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5) Shopping cart 2 contains (DVD-RW 3.0)

3.BeanCreationException

4.none of the mentioned

Posted Date:-2022-01-02 16:32:52


Question:
Inner Bean can be retrieved by it’s name.

1. True

2. False

3.error

4.None of these

Posted Date:-2022-01-02 16:16:24


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

1.True

2. False

3.error

4.all of the mentioned

Posted Date:-2022-01-02 15:59:28


Question:
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>

1.Yes

2.No

3.error

4.None of these

Posted Date:-2022-01-02 16:15:18


Question:
Method used to process bean after initialization callback

1. scope

2.getBean

3. postProcessAfterInitialization()

4.it’s own constructor

Posted Date:-2022-01-02 16:39:49


Question:
Method used to process bean before initialization callback

1.scope

2.postProcessAfterInitialization()

3.postProcessBeforeInitialization()

4.it’s own constructor

Posted Date:-2022-01-02 16:39:22


Question:
PathCheckingBeanPostProcessor will not work properly in case of:-

1. XML Configuration

2. Java based Configuration

3. JSR Annotation

4.none of the mentioned

Posted Date:-2022-01-02 16:41:53


Question:
PropertyPathFactoryBean declares a bean from an:-

1. Object Property

2.Property Path

3. All of the mentioned

4.none of the mentioned

Posted Date:-2022-01-02 16:20:00


Question:
Purpose of Static Factory Method?

1.Static method to create an object

2.Initialize bean

3. All of the mentioned

4.None of the mentioned

Posted Date:-2022-01-02 15:50:44


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

1.True

2.False

3.error

4.None of these

Posted Date:-2022-01-02 15:58:16


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

1.True

2.False

3.error

4.None of these

Posted Date:-2022-01-02 16:20:46


Question:
The Spring Expression Language can be accessed by:-

1. XML configuration

2.Annotations

3.None of the mentioned

4. All of the mentioned

Posted Date:-2022-01-02 16:26:07


Question:
Ways to declare bean from a static field?

1. FieldRetrievingFactoryBean

2.util:contant

3.All of the mentioned

4.none of the mentioned

Posted Date:-2022-01-02 16:11:40


Question:
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>

1. BeanCreationException

2.Bean Created

3.ClassPathException

4.none of the mentioned

Posted Date:-2022-01-02 15:53:28


Question:
Which annotation is used as a substitute of destroy method?

1. @PostConstruct

2.@PreDestroy

3.None of the mentioned

4. All of the mentioned

Posted Date:-2022-01-02 16:37:07


Question:
Which annotation is used as a substitute of initialization method?

1.@PostConstruct

2. @PreDestroy

3.None of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:36:06


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

1. setScope

2. scope

3. getScope

4.none of the mentioned

Posted Date:-2022-01-02 16:28:58


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

1.name

2.id

3.class

4.constructor-args

Posted Date:-2022-01-02 15:39:27


Question:
Which attribute is used to specify static factory-method?

1.factory-method

2.default-init method

3. destroy method

4.lazy-init method

Posted Date:-2022-01-02 15:43:48


Question:
Which Attribute is used to specify the bean declared?

1. factory-bean

2. scope

3. getBean

4. declareBean

Posted Date:-2022-01-02 15:59:48


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

1. PropertyPlaceholderConfigurer

2.PropertyPlaceholderRegister

3. PropertyGetPath

4. None of the mentioned

Posted Date:-2022-01-02 16:42:16


Question:
Which configuration can be used for Dependency Injection?

1. XML Configuration

2. Annotation Configuration

3. Java Based Configuration

4.All of the mentioned

Posted Date:-2022-01-02 16:37:42


Question:
Which interface defines methods for resolving text messages

1. MessageSource

2. ApplicationListener

3.ApplicationContextListener

4.TextEvent

Posted Date:-2022-01-02 16:42:38


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

1.StorageConfig

2. Marker

3.None of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:41:07


Question:
Which interface is used to perform destruction of beans?

1. InitializingBean

2. Disposablebean

3.None of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:34:15


Question:
Which interface is used to perform initialization of beans?

1. InitializingBean

2.Disposablebean

3.None of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:33:36


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

1.shutdownHook

2. destroy method

3. none of the mentioned

4.all of the mentioned

Posted Date:-2022-01-02 16:40:13


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

1. getPath

2. setPath

3.value

4.auto-wiring

Posted Date:-2022-01-02 16:41:31


Question:
Which of the following are considered valid beans?

1. Singleton

2. Prototype

3.All of the mentioned

4.none of the mentioned

Posted Date:-2022-01-02 16:31:45


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

1.static factory method

2.default-init method

3.destroy method

4.lazy-init method

Posted Date:-2022-01-02 15:42:17


Question:
Which one is the default scope of the beans?

1.Prototype

2.Session

3.Request

4.Singleton

Posted Date:-2022-01-02 16:30:03


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

1.Singleton

2. Prototype

3.Session

4.Request

Posted Date:-2022-01-02 16:30:43


More MCQS

  1. Spring Mcq Set 1
  2. Spring Mcq Set 2
  3. Spring Mcq Set 3
  4. Spring Mcq Set 4
  5. Spring Mcq Set 5
  6. Spring Mcq Set 6
  7. Spring Mcq Set 7
  8. Spring Mcq Set 8
  9. Spring Mcq Set 9
  10. Spring Mcq Set 10
  11. Spring Mcq Set 11
  12. Spring Mcq Set 12
  13. Spring Mcq Set 13
  14. Spring Mcq Set 14
  15. Spring Mcq Set 15
  16. Spring Mcq Set 16
  17. Spring Mcq Set 17
  18. Spring Mcq Set 18
  19. Spring Mcq Set 19
  20. Spring Mcq Questions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!