250+ TOP MCQs on Transformation and Error handling and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) on “Transformation and Error handling”.

1. To send a message into the bus and transform it before working with it further.
a) adding extra headers or augmenting the payload
b) transformer
c) all of the mentioned
d) none of the mentioned

Answer: c
Clarification: You might also want to transform a message by enriching it—adding extra headers or augmenting the payload so that components downstream in the processing pipeline can benefit from it. Use a transformer component to take a Message of a payload and send the Message out with a payload of a different type.

2. Spring Integration provides a transformer message endpoint to permit the augmentation of the message headers.
a) True
b) False

Answer: a
Clarification: Spring Integration provides a transformer message endpoint to permit the augmentation of the message headers or the transformation of the message itself. In Spring Integration, components are chained together, and output from one component is returned by way of the method invoked for that component.

3.The output is constructed dynamically using MessageBuilder to create a message that has the same payload as the input message as well as copy the existing headers and adds an extra header:

import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageBuilder;
import java.util.Map;
public class InboundJMSMessageToCustomerWithExtraMetadataTransformer {
	@Transformer
	public Message<Customer> transformJMSMapToCustomer(
	Message<Map<String, Object>> inboundSpringIntegrationMessage) {
	Map<String, Object> jmsMessagePayload =
	inboundSpringIntegrationMessage.getPayload();
	Customer customer = new Customer();
	customer.setFirstName((String) jmsMessagePayload.get("firstName"));
	customer.setLastName((String) jmsMessagePayload.get("lastName"));
	customer.setId((Long) jmsMessagePayload.get("id"));
	return MessageBuilder.withPayload(customer)
	.copyHeadersIfAbsent( inboundSpringIntegrationMessage.getHeaders())
	.setHeaderIfAbsent("randomlySelectedForSurvey", Math.random() > .5)
	.build();
	}
}

a) randomlySelected
b) randomlySelectedForSurvey
c) randomly
d) none of the mentioned

Answer: b
Clarification: As before, this code is simply a method with an input and an output. The output is constructed dynamically using MessageBuilder to create a message that has the same payload as the input message as well as copy the existing headers and adds an extra header: randomlySelectedForSurvey.

4. Spring Integration provides the ability to catch exceptions and send them to an error channel of your choosing. By default, it’s a global channel called :-
a) error
b) exceptionChannel
c) exception
d) errorChannel

Answer: d
Clarification: You can have components subscribe to messages from this channel to override the exception handling behavior.

5. The errorChannel doesn’t need to be a service-activator.
a) True
b) False

Answer: a
Clarification: We just use it for convenience here. The code for the following service-activator depicts some of the machinations you might go through to build a handler for the errorChannel.

6. All errors thrown from Spring Integration components will be a subclass of:-
a) Messaging
b) MessagingException
c) Exception
d) None of the mentioned

Answer: b
Clarification: MessagingException carries a pointer to the original Message that caused an error, which you can dissect for more context information.

7. One way to discriminate by Exception type is to use:-
a) org.springframework.integration.router.ErrorMessageExceptionType
b) org.springframework.integration.router.ErrorMessageException
c) org.springframework.integration.router.ErrorMessageExceptionTypeRouter
d) none of the mentioned

Answer: c
Clarification: Sometimes, more specific error handling is required. One way to discriminate by Exception type is to use the org.springframework.integration.router.ErrorMessageExceptionTypeRouter class.

8. Sending all the errors to the same channel can eventually lead to a large switch-laden class that’s too complex to maintain.
a) True
b) False

Answer: a
Clarification: Instead, it’s better to selectively route error messages to the error channel most appropriate to each integration.

9. You can explicitly specify on what channel errors for a given integration should go.
a) True
b) False

Answer: a
Clarification: A component (service-activator) that upon receiving a message, adds a header indicating the name of the error channel.

10. Spring Integration will use that header and forward errors encountered in the processing of this message to that channel.
a) True
b) False

Answer: a
Clarification: The following example shows a component (service-activator) that upon receiving a message, adds a header indicating the name of the error channel. Spring Integration will use that header and forward errors encountered in the processing of this message to that channel.

import org.apache.log4j.Logger;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageHeaders;
import org.springframework.integration.message.MessageBuilder;
public class ServiceActivatorThatSpecifiesErrorChannel {
private static final Logger logger = Logger.getLogger(
	ServiceActivatorThatSpecifiesErrorChannel.class);
	@ServiceActivator
	public Message<?> startIntegrationFlow(Message<?> firstMessage)
	throws Throwable {
	return MessageBuilder.fromMessage(firstMessage).
	setHeaderIfAbsent( MessageHeaders.ERROR_CHANNEL,
	"errorChannelForMySolution").build();
	}
}

11. All errors that come from the integration in which this component is used will be directed to:-

import org.apache.log4j.Logger;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageHeaders;
import org.springframework.integration.message.MessageBuilder;
public class ServiceActivatorThatSpecifiesErrorChannel {
private static final Logger logger = Logger.getLogger(
	ServiceActivatorThatSpecifiesErrorChannel.class);
	@ServiceActivator
	public Message<?> startIntegrationFlow(Message<?> firstMessage)
	throws Throwable {
	return MessageBuilder.fromMessage(firstMessage).
	setHeaderIfAbsent( MessageHeaders.ERROR_CHANNEL,
	"errorChannelForMySolution").build();
	}
}

a) customErrorChannel
b) customError
c) errorChannel
d) none of the mentioned

Answer: a
Clarification: Thus, all errors that come from the integration in which this component is used will be directed to customErrorChannel, to which you can subscribe any component you like.

 

250+ TOP MCQs on Pointcut Definitions and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) on “Pointcut Definitions”.

1. PointCut definitions can’t be reused again
a) True
b) False
Answer: b
Clarification: Like many other AOP implementations, AspectJ also allows you to define a pointcut independently to be reused in multiple advices.

2. Annotation used to refer poincuts?
a) @Pointcut
b) @PointcutExecution
c) @PointcutBefore
d) None of the mentioned
Answer: a
Clarification: In an AspectJ aspect, a pointcut can be declared as a simple method with the @Pointcut annotation.

3. what will be the output of the code snippet?

   package com.apress.springrecipes.calculator;
   import org.aspectj.lang.annotation.Aspect;
   import org.aspectj.lang.annotation.Pointcut;
   @Aspect
   public class CalculatorPointcuts 
   {
	@Pointcut("execution(* *.*(..))")
	public void loggingOperation() {}
   }
 
   package com.apress.springrecipes.calculator;
   @Aspect
public class CalculatorLoggingAspect 
{
   ...
   @Before("CalculatorPointcuts.loggingOperation()")
   public void logBefore(JoinPoint joinPoint) 
   {
   ...
   }
   @AfterReturning(
   pointcut = "loggingOperation()",
   returning = "result")
   public void logAfterReturning(JoinPoint joinPoint, Object result)
   {
   throw new IllegalArgumentException();
   }
   @AfterThrowing(
   pointcut = "CalculatorPointcuts.loggingOperation()",
   throwing = "e")
   public void logAfterThrowing(JoinPoint joinPoint, IllegalArgumentException e)
   {
   ...
   }
   @Around("CalculatorPointcuts.loggingOperation()")
   public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable 
   {
   ...
   }
}

a) Runtime Error
b) IllegalArgument Exception
c) BeanCreation Exception
d) None of the mentioned
Answer: c
Clarification: When you refer to this pointcut, you have to include the class name as well. If the class is not located in the same package as the aspect, you have to include the package name also.

4. Language used to set various kinds of join points
a) AspectJ pointcut language
b) Java pointcut language
c) XML pointcut language
d) None of the mentioned
Answer: a
Clarification: The AspectJ pointcut language is a powerful expression language that can match various kinds of join points.

5. Spring AOP only supports method execution join points for the beans in its IoC container
a) True
b) False
Answer: a
Clarification: If you use a pointcut expression out of this scope, an IllegalArgumentException will be thrown.

6. Is the following pointcut expression correct?
execution(* ArithmeticCalculator.*(..))
a) Yes
b) No
c) If every target class is in same package
d) Depends where target class is located
Answer: c
Clarification: You can omit the package name if the target class or interface is located in the same package as this aspect.

7. The annotations must be added to the implementation class but not the interface
a) True
b) False
Answer: a
Clarification: Annotations must be added to the implementation class but not the interface, as they will not be inherited.

8. Which of the following pattern is used to match bean name?
a) bean(*Calculator)
b) bean(Calculator)
c) bean(com.appress.spring.Calculator)
d) None of the mentioned
Answer: a
Clarification: The following pointcut expression matches beans whose name ends with Calculator.

9. Bean name patterns are supported by all configurations(XML,Java,AspectJ)
a) True
b) False
Answer: b
Clarification: This pointcut type is supported only in XML-based Spring AOP configurations, not in AspectJ annotations.

10. Expressions which returns Parameters of pointcuts?
a) target
b) args
c) none of the mentioned
d) all of the mentioned
Answer: d
Clarification: The expressions target() and args() capture the target object and argument values of the current join point and expose them as pointcut parameters.

11. Are logical operators valid in pointcut expressions?
a) Yes
b) No
Answer: a
Clarification: In AspectJ, pointcut expressions can be combined with the operators && (and), || (or), and ! (not).

12. Method which checks if all target classes are matched
a) matches()
b) pair()
c) matchTargetClass()
d) none of the mentioned
Answer: a
Clarification: If the matches() method always returns true, all target classes will be matched.

13. Spring supports operations on pointcuts:-
a) notably
b) union
c) intersection
d) all of the mentioned
Answer: d
Clarification: Union means the methods that either pointcut matches.
Intersection means the methods that both pointcuts match.
Union is usually more useful.

14. Pointcuts can be composed using:-
a) org.springframework.aop.support.Pointcuts class
b) composablePointcut class
c) all of the mentioned
d) none of the mentioned
Answer: c
Clarification: Using the static methods in the org.springframework.aop.support.Pointcuts class, or using the ComposablePointcut class in the same package.

15. Pointcut used to parse an AspectJ pointcut expression string
a) org.springframework.aop.aspectj.AspectJExpressionPointcut
b) org.springframework.aop.aspectj.AspectJExpressionPointcutString
c) org.springframework.aop.aspectj.AspectJExpressionString
d) org.springframework.aop.aspectj.AspectJPointcuttoString
Answer: a
Clarification: Since 2.0, the most important type of pointcut used by Spring is org.springframework.aop.aspectj.AspectJExpressionPointcut. This is a pointcut that uses an AspectJ supplied library to parse an AspectJ pointcut expression string.

250+ TOP MCQs on REST Service with Spring and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) on “REST Service with Spring”.

1. To publish a REST service with Spring.
a) publishing an application’s data as a REST service
b) accessing data from third-party REST services
c) none of the mentioned
d) all of the mentioned
Answer: d
Clarification: One involves publishing an application’s data as a REST service, the other one involves accessing data from third-party REST services to be used in an application.

2. Publishing an application’s data as a REST service requires.
a) @RequestMapping
b) @PathVariable
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: Publishing an application’s data as a REST service revolves around the use of the Spring MVC annotations @RequestMapping and @PathVariable.

3. Spring supports a series of mechanisms to generate a REST service payload.
a) True
b) False
Answer: a
Clarification: This recipe will explore the simplest mechanism, which involves the use of Spring’s MarshallingView class.

4. Annotation added as an input parameter to the handler method.
a) @PathVariable
b) @Path
c) @PathLocale
d) None of the mentioned
Answer: a
Clarification: The @PathVariable annotation is added as an input parameter to the handler method, per Spring’s MVC conventions, in order for it to be used inside the handler method body.

5. Notation for defining REST endpoints.
a) { }
b) *
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: In addition to supporting the { } notation, it’s also possible to use a wildcard * notation for defining REST endpoints.

6. General-purpose class that allows a response to be rendered using a marshaller.
a) MarshallingView
b) Marshalling
c) View
d) All of the mentioned
Answer: a
Clarification: The membertemplate view is defined as a MarshallingView type, which is a general-purpose class that allows a response to be rendered using a marshaller.

7. Marshalling is the process of transforming an in-memory representation of an object into a data format.a
a) True
b) False
Answer: a
Clarification: Therefore, for this particular case, a marshaller is charged with transforming a Member object into an XML data format.

8. The marshaller used by MarshallingView belongs to one of a series of XML marshallers.
a) Jaxb2Marshaller
b) XmlBeansMarshaller
c) CastorMarshalle
d) All of the mentioned
Answer: d
Clarification: The marshaller used by MarshallingView belongs to one of a series of XML marshallers provided by Spring—Jaxb2Marshaller. Other marshallers provided by Spring include CastorMarshaller, JibxMarshaller, XmlBeansMarshaller, and XStreamMarshaller.

9. To configure Jaxb2Marshaller marshaller we require.
a) ClassesToBeBound
b) ContextPath
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: The Jaxb2Marshaller marshaller requires to be configured with either a property named classesToBeBound or contextPath.

10. In the case of classesToBeBound, the classes assigned to this property, indicate the class (i.e., object) structure that is to be transformed into XML.
a) True
b) False
Answer: a
Clarification: The Jaxb2Marshaller marshaller requires to be configured with either a property named classesToBeBound or contextPath.

11. Annotation which allows the Jaxb2Marshaller marshaller to detect a class’s (i.e., object’s) fields.
a) @XmlRootElement
b) @XmlRoot
c) @NotNull
d) None of the mentioned
Answer: a
Clarification: This annotation allows the Jaxb2Marshaller marshaller to detect a class’s (i.e., object’s) fields and transform them into XML data.

12. Accessing a third-party REST service inside a Spring application.
a) RestTemplate Class
b) ViewResolver
c) InternalViewResolver
d) View
Answer: a
Clarification: Accessing a third-party REST service inside a Spring application revolves around the use of the Spring RestTemplate class.

13. REST service end point comprises an address.
a) starts with http:// and ends with ?
b) starts with http:// and ends with &
c) no certain URL is specified
d) depends upon the platform used
Answer: a
Clarification: The structure of the REST service end point comprises an address, which starts with http:// and ends with ?, as well as a series of parameters that start with ? and are delimited by &, each represented by a key and value divided by =.

14. XML tag which represents information related to a REST service request.
a) Result
b) Title
c) None of the mentioned
d) All of the mentioned
Answer: d
Clarification: The actual meaning of the payload is highly dependent on a REST service. In this case, the XML tags (e.g., Result, Title ) are definitions set forth by Yahoo, while the character data enclosed in each XML tag represents information related to a REST service request.

15. RestTemplate class method which performs an HTTP HEAD operation.
a) headForHeaders(String, Object…)
b) getForObject(String, Class, Object…)
c) postForLocation(String, Object, Object…)
d) postForObject(String, Object, Class, Object…)
Answer: a
Clarification: headforHeaders() is a RestTemplate class method based on HTTP protocol request methods.

250+ TOP MCQs on Using the Simple JDBC Template and Handling Exceptions and Answers

Java Spring Quiz on “Using the Simple JDBC Template and Handling Exceptions”.

1. JdbcTemplate that takes advantage of Java 1.5 features such as autoboxing, generics, and variable-length arguments to simplify its usage.
a) org.springframework.jdbc.core.JdbcTemplate
b) org.springframework.jdbc.core.simple.SimpleJdbcTemplate
c) org.springframework.jdbc.*
d) none of the mentioned
Answer: b
Clarification: org.springframework.jdbc.core.simple.SimpleJdbcTemplate is an evolution of JdbcTemplate that takes advantage of Java 1.5 features such as autoboxing, generics, and variable-length arguments to simplify its usage.

2. JdbcTemplate require statement parameters to be passed as an object array.
a) True
b) False
Answer: a
Clarification: In SimpleJdbcTemplate, they can be passed as variable-length arguments; this saves you the trouble of wrapping them in an array.

3. To use SimpleJdbcTemplate:-
a) instantiate it directly
b) retrieve its instance by extending the SimpleJdbcDaoSupport class
c) all of the mentioned
d) none of the mentioned
Answer: c
Clarification: To use SimpleJdbcTemplate, you can either instantiate it directly or retrieve its instance by extending the SimpleJdbcDaoSupport class.

4. SimpleJdbcTemplate offers a convenient batch update method in the form of:-
a) Vector
b) Set
c) Map
d) List
Answer: d
Clarification: SimpleJdbcTemplate offers a convenient batch update method for you to specify a SQL statement and a batch of parameters in the form of List

5. Method has a warning from the Java compiler because of an unchecked conversion from List to List.
a) findAll()
b) query()
c) update()
d) batchUpdate()
View Answer

Answer: a
Clarification: When using the classic JdbcTemplate, the findAll() method has a warning from the Java compiler because of an unchecked conversion from List to List. This is because the return type of the query() method is List rather than the type-safe List.

6. The return type of the queryForObject() method will be determined by the class argument (e.g., String.class).
a) True
b) False
Answer: a
Clarification: So, there’s no need for you to perform typecasting manually.

7. Named SQL parameters are specified by name (starting with a colon) rather than by position.
a) True
b) False
Answer: a
Clarification: Another option when binding SQL parameters in the Spring JDBC framework is to use named parameters.

8. Named parameters are supported only in SimpleJdbcTemplate.
a) True
b) False
Answer: a
Clarification: Named parameters are supported only in SimpleJdbcTemplate and NamedParameterJdbcTemplate.

9. Implementations of the SqlParameterSource interface:-
a) MapSqlParameterSource
b) BeanPropertySqlParameterSource
c) none of the mentioned
d) all of the mentioned
Answer: d
Clarification: There are three implementations of the SqlParameterSource interface. The basic one is MapSqlParameterSource, which wraps a map as its parameter source.

10. The Spring framework offers a consistent data access exception-handling mechanism for its data access module.
a) True
b) False
Answer: a
Clarification: In general, all exceptions thrown by the Spring JDBC framework are subclasses of org.springframework.dao.DataAccessException, a type of RuntimeException that you are not forced to catch.

11. In your DAO methods, you neither need to surround the code with a try/catch block nor declare throwing an exception in the method signature.
a) True
b) False
Answer: a
Clarification: This is because DataAccessException (and therefore its subclasses, including DuplicateKeyException) is an unchecked exception that you are not forced to catch.

12. The direct parent class of DataAccessException is:-
a) RuntimeException
b) NestedRuntimeException
c) Exception
d) Throwable
Answer: b
Clarification: A core Spring exception class that wraps another exception in a RuntimeException.

13. Which concrete exception in the DataAccessException hierarchy should be thrown?
a) errorCode
b) SQLState properties of the caught SQLException
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: As a DataAccessException wraps the underlying SQLException as the root cause, you can inspect the errorCode and SQLState properties with the following catch block.

14. Error code for The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint.
a) -1
b) 0
c) 23505
d) 1
Answer: a
Clarification: SQL State Message Text
23505 The statement was aborted because it would have caused a duplicate key value in a unique or primary.

15. How does the Spring JDBC framework know that state 23505 should be mapped to DuplicateKeyException?
a) error code
b) SQL state
c) all of the mentioned
d) none of the mentioned
Answer: c
Clarification: The error code and SQL state are database specific, which means different database products may return different codes for the same kind of error.


Java Spring for quizzes,

250+ TOP MCQs on Splitters and Aggregators,Routing and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) on “Splitters and Aggregators,Routing”.

1. To fork the process flow from one component to many, either all at once or to a single one based on a predicate condition.
a) splitter
b) fork
c) all of the mentioned
d) none of the mentioned
Answer: a
Clarification: You can use a splitter component (and maybe its cohort, the aggregator component) to fork and join (respectively) control of processing.

2. A splitter takes an input message and asks you, the user of the component, on what basis it should split the Message.
a) True
b) False
View Answer

Answer: a
Clarification: You’re responsible for providing the split functionality.

3. Spring Integration ships with useful splitters that require no customization.
a) Splitter
b) XPathMessageSplitter
c) All of the mentioned
d) None of the mentioned
Answer: b
Clarification: In a few cases, Spring Integration ships with useful splitters that require no customization. One example is the splitter provided to partition an XML payload along an XPath query, XPathMessageSplitter.

4. Return type of the method annotated by the @Splitter annotation is of type:-
a) java.util.Collection
b) java.util.Date
c) all of the mentioned
d) none of the mentioned
Answer: a
Clarification: The configuration for this is not terribly different from the previous solutions. The Java code is just about the same as well, except that the return type of the method annotated by the @Splitter annotation is of type java.util.Collection.

5. Annotation which collects a series of messages (based on some correlation that you help Spring Integration make between the messages).
a) @After
b) @Splitter
c) @Aggregator
d) None of the mentioned
Answer: c
Clarification: An @Aggregator collects a series of messages (based on some correlation that you help Spring Integration make between the messages) and publishes a single message to the components downstream.

6. To determine how many messages to read until it can stop:-
a) SequenceSizeCompletionStrategy
b) SequenceSizeCompletion
c) SequenceSize
d) None of the mentioned
Answer: a
Clarification: There are many ways for Spring Integration to correlate incoming messages. To determine how many messages to read until it can stop, it uses the class SequenceSizeCompletionStrategy, which reads a well known header value (aggregators are often used after a splitter.

7. For correlation when you might not have a size but know that you’re expecting messages that share a common header value within a known time, Spring Integration provides the HeaderAttributeCorrelationStrategy.
a) True
b) False
Answer: a
Clarification: In this way, it knows that all messages with that value are from the same group, in the same way that your last name identifies you as being part of a larger group.

8. The only custom logic is a POJO with an @Aggregator annotation on a method expecting a collection of Message objects.
a) True
b) False
View Answer

Answer: a
Clarification: It could, of course, be a collection of Customer objects, because they are what you’re expecting as output from the previous splitter.

9. You want to conditionally move a message through different processes based on some criteria.
a) router component
b) EAI
c) all of the mentioned
d) none of the mentioned
Answer: a
Clarification: You can use a router component to alter the processing flow based on some predicate. You can also use a router to multicast a message to many subscribers (as you did with the splitter).

10. There are some convenient default routers available to fill common needs:-
a) PayloadTypeRouter
b) PayloadType
c) Payload
d) None of the mentioned
Answer: a
Clarification: There are some convenient default routers available to fill common needs, such as payload-type–based routing (PayloadTypeRouter) and routing to a group or list of channels (RecipientListRouter).

11. To receive messages from an external system and process them using Spring Integration.
a) channel
b) channel adapter
c) EJP
d) none of the mentioned
Answer: b
Clarification: Spring Integration makes it trivially easy to build one.

12. Adapters are opaque in nature.
a) True
b) False
Answer: a
Clarification: Your external system interfaces with the adapter.

13. Sometimes, functionality is made available from within the application via:-
a) Stable API
b) Cohesive API
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: Sometimes, functionality is made available from within the application via a cohesive, stable API but in a component model or form that isn’t directly accessible to the bus.

14. You use Spring Integration’s inbound-channel-adapter element to wire the TwitterMessageSource and a poller element.
a) True
b) False
Answer: a
Clarification: The poller element is configured to run every 10 seconds and to consume as many as 100 messages each time it runs.

15. The API surfaces a Paging object, which works something like Criteria in Hibernate.
a) True
b) False
Answer: a
Clarification: You can configure how many results to return using the count property. The most interesting option is called the sinceId, which lets you search for all records occurring after the Status having the ID equal to the value given as the sinceId.


250+ TOP MCQs on Introducing Behaviors and States to Your Beans and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) on “Introducing Behaviors and States to Your Beans”.

1. Which special type of advice is used to implement an interface?
a) Introduction
b) Before
c) After
d) AfterSpecial
Answer: a
Clarification: It allows your objects to implement an interface dynamically by providing an implementation class for that interface.

2. Introduction advice helps in implementing multiple inheritance
a) True
b) False
Answer: a
Clarification: You are able to introduce multiple interfaces with multiple implementation classes to your objects at the same time.

3. In introduction advice you have to modify class to introduce new methods
a) True
b) False
Answer: b
Clarification: You can introduce methods to your existing classes even without source code available.

4. How does an Introduction advice do this in Spring?
a) dynamic proxy
b) web proxy
c) implements org.springframework.net.bundle interface
d) none of the mentioned
Answer: a
Clarification: Introduction works by adding an interface to the dynamic proxy.

5. Annotation used to declare an introduction
a) Before
b) After
c) @DeclareParents
d) None of the mentioned
Answer: c
Clarification: In this aspect, you can declare an introduction by annotating an arbitrary field with the @DeclareParents annotation.

6. Target Classes can be denoted by Introduction Annotation
a) True
b) False
Answer: a
Clarification: The value attribute of the @DeclareParents annotation type indicates which classes are the targets for this introduction.

7. Attribute used to specify implementation class
a) no such attribute
b) defaultImpl
c) defaultInterface
d) defaultImplement
Answer: b
Clarification: The interface to introduce is determined by the type of the annotated field. Finally, the implementation class used for this new interface is specified in the defaultImpl attribute.

8. How to keep track of the usage of your beans
a) Calling Count
b) Last modified date
c) New Interface to your object
d) All of the mentioned
Answer: d
Clarification: You can introduce a new interface to your objects with an implementation class that holds the state field.

9. How to introduce counter field to original bean class?
a) Using Spring AOP
b) Implementing interface
c) AspectJ Pointcut
d) None of the mentioned
Answer: a
Clarification: Since there is no field for storing the counter value in the original classes, you need to introduce one with Spring AOP.

10. Tag used to declare aspects
a) aop:config
b) aop:auto-proxy
c) aop:autowire
d) None of the mentioned
Answer: a
Clarification: In the bean configuration file, all the Spring AOP configurations must be defined inside the aop:config element.