iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

958 questions | 100% Free

Q.901Easy

Which annotation is used to mark a class as a Spring Bean in the latest Spring Framework?

Q.902Easy

What is the primary purpose of Dependency Injection (DI) in Spring Framework?

Q.903Easy

Which of the following is NOT a valid Spring bean scope in Spring 5.x+?

Q.904Easy

What does @Autowired annotation do in Spring?

Q.905Easy

Which XML element is used to define a bean in Spring XML configuration?

Q.906Medium

A Spring application requires constructor-based dependency injection for a mandatory dependency. Which approach is best?

Q.907Medium

What is the default scope of a Spring Bean?

Q.908Medium

Which of the following best describes IoC (Inversion of Control) in Spring?

Q.909Medium

A developer needs to inject a bean only if it exists, otherwise skip injection. Which annotation should be used?

Q.910Medium

What is the role of ApplicationContext in Spring Framework?

Q.911Medium

Which annotation is used to define configuration classes in Spring that replace XML configuration?

Q.912Medium

Consider a scenario where multiple beans of the same type exist. How can you specify which bean to inject?

Q.913Medium

What is the difference between @Bean and @Component annotations?

Q.914Medium

A Spring Boot application starts with ClassPathXmlApplicationContext('application.xml'). What does this do?

Q.915Medium

Which Spring concept ensures that the same bean instance is reused throughout the application lifecycle?

Q.916Hard

An enterprise application needs different bean implementations based on environment (dev/prod). Which approach is most suitable?

Q.917Hard

What happens when a prototype-scoped bean has a dependency on a singleton-scoped bean in Spring?

Q.918Hard

In Spring Framework 2024-25, which feature allows lazy initialization of beans?

Q.919Hard

A microservices architecture uses Spring with circular dependency between ServiceA and ServiceB. What is the best solution?

Q.920Easy

In Spring Framework, what is the primary purpose of the @Autowired annotation?