Spring Certified Professional 2023 · Free Practice Question Medium

Question 26

Which of the following options are true? (select 2)


Using field injection has the following results:

  • A

    less code to write

  • B

    easy to test

  • C

    safer code

  • D

    more complicated to test

Reveal correct answers

Correct answers: A, D

Explanation

Answer: more complicated to test, unsafe, but less code to write.


Field injection:

  • ++ less code to write

  • -- unsafe code

  • - more complicated to test


Constructor injection:

  • ++ safe code

  • - more code to write (see the hint to Lombok)

  • + easy to test


Details : http://odrotbohm.de/2013/11/why-field-injection-is-evil/

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need