🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Spring Core and DI: all 10 questions

Quiz: Spring Core and DI · Question 7 of 10

Which error do you get when two beans of the same type exist and neither is @Primary nor selected by @Qualifier?

Which error do you get when two beans of the same type exist and neither is @Primary nor selected by @Qualifier?

  1. A.NoUniqueBeanDefinitionException
  2. B.NoSuchBeanDefinitionException
  3. C.NullPointerException
  4. D.BeanCreationNotAllowedException
Answer & explanation

Correct answer: NoUniqueBeanDefinitionException

Spring cannot decide which of the two candidates to inject.

Can you get the rest right without peeking?

Take the timed Quiz: Spring Core and DI quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →