My Report

Spring Practice Test 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. It's possible to replace the original bean instance with a brand-new instance in your bean post processor

2. Alternative annotative way to specify precedence of aspects?

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

What will be the output:-

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

5. Which interface is implemented to specify precedence of aspects?

6. Method that converts string into a property value

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

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

9. Which tag is also allowed by static field?

10. Which method provided by ExecutorService is used to check whether job is finished or cancelled


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.