JMX (Java Management Extensions) Question:

Download Job Interview Questions and Answers PDF

Why is dependency injection useful?

JMX Interview Question
JMX Interview Question

Answer:

Different collaborators for different environments can be injected - test, production, test-database, real database. This allows classes to be tested independent of its collaborators (makes it easy to pass in stub or mock objects).

Download JMX Interview Questions And Answers PDF

Previous QuestionNext Question
What is dependency injection?How is dependency injection performed in the bean-file XML?