adplus-dvertising
frame-decoration

Question

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;

a.

A and B are equivalent

b.

A and B provides different functionality

c.

Runtime Error in A

d.

Exception in B

Answer: (a).A and B are equivalent

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Comment on the following pieces of code.

Similar Questions

Discover Related MCQs

Q. Declaring Beans using:-Ways to declare bean from a static field?

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

Q. Declaring Beans using:-

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

Q. Which tag is also allowed by static field?

Q. Declaring bean form object properties can be done using:-

Q. Inner Bean can be retrieved by it’s name.

Q. PropertyPathFactoryBean declares a bean from an:-

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

Q. Alternate way of PropertyPathFactoryBean to declare a bean.

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

Q. The Spring Expression Language can be accessed by:-

Q. A bean can be requested by:-

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

Q. Which one is the default scope of the beans?

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

Q. Session Creates a single bean instance per HTTP request, only valid in the context of a web application?

Q. Which of the following are considered valid beans?

Q. Which interface is used to perform initialization of beans?

Q. Which interface is used to perform destruction of beans?