This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: In the bean configuration file, all the Spring AOP configurations must be defined inside the aop:config element.
Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in Spring
- Participate in Spring Certification Contest
- Become a Top Ranker in Spring
- Take Spring Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for Spring Internship
- Buy Information Technology Books
- Apply for Programming Internship
- Buy Spring Books
- Practice Programming MCQs