More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Interview Questions and Answers for 'Spring' - 81 question(s) found - Order By Newest
Very frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.
x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.
Sample code:
String x = new String("str");
String y = new String("str");
System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true
Ans. Spring enables developers to develop enterprise-class applications using POJOs. The benefit of using only POJOs is that you do not need an EJB container product.
Spring is organized in a modular fashion. Even though the number of packages and classes are substantial, you have to worry only about ones you need and ignore the rest.
Spring does not reinvent the wheel instead, it truly makes use of some of the existing technologies like several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, other view technologies.
Testing an application written with Spring is simple because environment-dependent code is moved into this framework. Furthermore, by using JavaBean-style POJOs, it becomes easier to use dependency injection for injecting test data.
Spring is web framework is a well-designed web MVC framework, which provides a great alternative to web frameworks such as Struts or other over engineered or less popular web frameworks.
Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions.
Lightweight IoC containers tend to be lightweight, especially when compared to EJB containers, for example. This is beneficial for developing and deploying applications on computers with limited memory and CPU resources.
Spring provides a consistent transaction management interface that can scale down to a local transaction
Ans. MVC is a Design Pattern that facilititates loose coupling by segregating responsibilities in a Web application
1. Controller receives the requests and handles overall control of the request
2. Model holds majority of the Business logic, and
3. View comprise of the view objects and GUI component
Help us improve. Please let us know the company, where you were asked this question :
Ans. Prototype scope - A new object is created each time it is injected/looked up. It will use new SomeClass() each time.
Singleton scope - It is the default scope. The same object is returned each time it is injected/looked up. Here it will instantiate one instance of SomeClass and then return it each time.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Spring caching makes use of its intercepting capabilities to add caching to method calls. Therefore, the entire object is cached and reused. Hibernate, on the other hand, has more domain-specific knowledge of the Entity being cached and can handle the objects more appropriately.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Spring configuration file is an XML file. This file contains the classes information and describes how these classes are configured and introduced to each other.
Help us improve. Please let us know the company, where you were asked this question :
Ans. The Spring container is able to autowire relationships between collaborating beans. This means that it is possible to automatically let Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory without using and elements.
Help us improve. Please let us know the company, where you were asked this question :
Q16. What are the various Auto Wiring types in Spring ?
Ans. By Name , By Type and Constructor.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   spring   spring container   dependency injection   auto wiring   auto wiring types   general electric   ge
Q17. When should we use prototype scope and singleton scope for beans ?
Ans. I like Spring as it comes with inbuilt Dependency Injection framework. It has great online community and support and is proven to work well with ORMs like Hibernate. If we are not working with ORM and DI, Struts 2 is also good.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  spring   struts   project lead   technical lead   techical architect
Q19. What is the difference betweeen @Inject and @Autowired ?
Ans. @Autowired and @Inject are similar in terms of functionality they achieve. @Inject is part of a new Java technology called CDI that defines a standard for dependency injection whereas @Autowired is a Spring specific annotation for dependency injection.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  spring   web frameworks   dependency injection   autowired   inject   spring annotations   ioc
Q20. Should we have instance variables in the Spring Bean which has been scoped as Singleton ?
Ans. No, if required we should only have final variables.Bean scoped singleton means that only one instance of the bean will be created and will be shared among different requests and hence instance variables will get shared too.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Spring Security is a powerful and highly customizable authentication and access control framework. It is the de facto standard for securing Spring-based applications.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No, there is no relationship between web.xml and spring.xml but you have to configure spring.xml in web.xml in order initialize beans when application starts up
Help us improve. Please let us know the company, where you were asked this question :
Ans. Spring is a lightweight framework which gives in-build DI(Dependency injection) and IOC(Inversion of control) features. Where DI is used for injecting one bean into the another bean like Inheritance in Java and IOC is a controller which will control the flow of the bean like bean creation and so on. We will use Bean Factory and Application Context for configuring.
Help us improve. Please let us know the company, where you were asked this question :