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.1Easy

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

Q.2Easy

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

Q.3Easy

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

Q.4Easy

What does @Autowired annotation do in Spring?

Q.5Easy

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

Q.6Medium

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

Q.7Medium

What is the default scope of a Spring Bean?

Q.8Medium

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

Q.9Medium

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

Q.10Medium

What is the role of ApplicationContext in Spring Framework?

Q.11Medium

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

Q.12Medium

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

Q.13Medium

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

Q.14Medium

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

Q.15Medium

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

Q.16Hard

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

Q.17Hard

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

Q.18Hard

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

Q.19Hard

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

Q.20Easy

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