Spring Interview Questions - 5 | Snaprecruit.com
Spring Interview Questions - 5 | Snaprecruit.com
JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing
Enterprises
Spring interview questions part 5
Spring interview questions part 5
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. Which one is the default scope of the beans?
A. Prototype
B. Session
C. Request
D. Singleton
Show Correct Answer
Correct Answer is :
Singleton
2. Which scope creates a new bean instance each time when requested?
A. Singleton
B. Prototype
C. Session
D. Request
Show Correct Answer
Correct Answer is :
Prototype
3. Session Creates a single bean instance per HTTP request, only valid in the context of a web application?
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
FALSE
4. Which of the following are considered valid beans?
A. Singleton
B. Prototype
C. All of the mentioned
D. None of the mentioned
Show Correct Answer
Correct Answer is :
All of the mentioned
5. What will be the output? public class ShoppingCart { private List
items = new ArrayList
(); public void addItem(Product item) { items.add(item); } public List
getItems() { return items; } }
import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); Product aaa = (Product) context.getBean("aaa"); Product cdrw = (Product) context.getBean("cdrw"); Product dvdrw = (Product) context.getBean("dvdrw"); ShoppingCart cart1 = (ShoppingCart) context.getBean("shoppingCart"); cart1.addItem(aaa); cart1.addItem(cdrw); System.out.println("Shopping cart 1 contains " + cart1.getItems()); ShoppingCart cart2 = (ShoppingCart) context.getBean("shoppingCart"); cart2.addItem(dvdrw); System.out.println("Shopping cart 2 contains " + cart2.getItems()); } }
A. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
C. BeanCreationException
D. None of the mentioned
Show Correct Answer
Correct Answer is :
Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
6. In above question if scope of shoppingCart named bean is prototype, then what will be the output? What will be the output?
A. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
C. BeanCreationException
D. None of the mentioned
Show Correct Answer
Correct Answer is :
Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
7. Which interface is used to perform initialization of beans?
A. InitializingBean
B. Disposablebean
C. None of the mentioned
D. All of the mentioned
Show Correct Answer
Correct Answer is :
InitializingBean
8. Which interface is used to perform destruction of beans?
A. InitializingBean
B. Disposablebean
C. None of the mentioned
D. All of the mentioned
Show Correct Answer
Correct Answer is :
Disposablebean
9. Alternate way of initialization method is:-
A. init-method attribute
B. afterPropertiesSet
C. destroy-method attribute
D. none of the mentioned
Show Correct Answer
Correct Answer is :
init-method attribute
10. Alternate way of destruction method is:-
A. init-method attribute
B. afterPropertiesSet
C. destroy-method attribute
D. none of the mentioned
Show Correct Answer
Correct Answer is :
destroy-method attribute
11. Which annotation is used as a substitute of initialization method?
A. @PostConstruct
B. @PreDestroy
C. None of the mentioned
D. All of the mentioned
Show Correct Answer
Correct Answer is :
@PostConstruct
12. .Which annotation is used as a substitute of destroy method?
A. @PostConstruct
B. @PreDestroy
C. None of the mentioned
D. All of the mentioned
Show Correct Answer
Correct Answer is :
@PreDestroy
13. Which configuration can be used for Dependency Injection?
A. XML Configuration
B. Annotation Configuration
C. Java Based Configuration
D. All of the mentioned
Show Correct Answer
Correct Answer is :
All of the mentioned
14. To validate Java beans in a web application using annotations.
A. XML
B. Java Based
C. JAR-303 standard
D. All of the mentioned
Show Correct Answer
Correct Answer is :
All of the mentioned
15. JSR-303 or bean validation can access beans through annotations.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
16. For validating beans Spring supports.
A. ad-hoc technique
B. jsr-303
C. all of the mentioned
D. none of the mentioned
Show Correct Answer
Correct Answer is :
all of the mentioned
17. JSR-303 can’t access java beans directly.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
FALSE
18. Annotation which indicates a field cannot be a null.
A. @NotNULL
B. @NotNull
C. All of the mentioned
D. None of the mentioned
Show Correct Answer
Correct Answer is :
@NotNull
19. Annotation used to indicate a field has to have a minimum of 2 characters.
A. @NotNull
B. @Size
C. @MaxSize
D. @size
Show Correct Answer
Correct Answer is :
@Size
20. Annotation which receives a value in the form regexp=”[email protected]+\\.[a-z]+”.
A. @Pattern
B. @EmailRecognizer
C. @Email
D. @Null
Show Correct Answer
Correct Answer is :
@Pattern
Similar Interview Questions
Search for latest jobs
Find Jobs