Spring - Interview Questions and Answers for 'Beans' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 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.
Label / Company      Label / Company / Text

   



Spring - Interview Questions and Answers for 'Beans' - 29 question(s) found - Order By Newest

 Q1. Why are Getter and Setter better than directly changing and retrieving fields ?

or

What is the significance of variable hiding in Java ?

or

Why it's preferred to keep variables private and allow their access through getter and setter methods ?
Core Java
Ans. 1. Methods can participate in runtime polymorphism whereas member variables cannot.

For example -

Vehicle vehicle = new Car();

car.getObjVariable();// will return variable defined in Car

whereas

car.variable

will return the variable from Car class irrespective of the object it holds.

2. Validations can be performed before setting the variables.

3. If the input format changes or some other value or calculated value needs to be returned , that can be absorbed by making change ( wrapping ) in the setter and getter. By this the call to method from outside or interface to the object will remain the same.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   beans   getter   setter


 Q2. What is the difference between single instance Web environment and Load Balanced Auto Scaling ? Amazon Web Services (AWS)
Ans. Single instance means there is only 1 instance that will bear all the traffic load whereas Load balanced server means that there will be a cluster of servers that will host the application and load will be balanced distributed among them. Auto Scaling means that the number of instances will be expanded / shrunken based on the rule. Rule could be the traffic count , response time etc.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     load balancing  auto scaling  aws  elastic beanstalk


 Q3. What is the difference between Singleton and Prototype Bean scope in Spring ?Spring
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 :   

   Like         Discuss         Correct / Improve     Spring beans  singleton bean scope  prototype bean scope     Asked in 1 Companies


 Q4. Difference between Java beans and Spring Beans ?Spring
Ans. Java Beans managed by Spring IoC are called Spring Beans.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   spring   beans


 Q5. What bean scopes does Spring support? Explain them.Spring
Ans. The Spring Framework supports following five scopes -

Singleton
prototype
request
session
global-session

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   spring   mvc   frameworks   web applications   beans   beans scope   at&t  fidelity


 Q6. How to generate getters and setters automatically in eclipse ?Eclipse
Ans. Right Click -> Source -> Generate Getters and Setters.

and it will open up a dialog wherein we can select the fields to generate Getters and Setters.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     eclipse   java beans


 Q7. Can we have two beans with same class with different bean id in spring ?Spring
Ans. Yes

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring beans     Asked in 1 Companies


 Q8. What are the types of applications we can create using Elastic Beanstalk ?Amazon Web Services (AWS)
Ans. Web Server and Worker

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     elastic beanstalk


 Q9. Q: What is default scope of bean in Spring framework?Spring
Ans. The default scope of bean is Singleton.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   spring   mvc   frameworks   web applications   bean


Very Frequently asked Spring question.
  Q10. What is bean auto wiring?Spring
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 :   

   Like         Discuss         Correct / Improve     j2ee   spring   mvc   frameworks   web applications   autowiring   beans   at&t   ge     Asked in 9 Companies        frequent


 Q11. What is IDE ? List few Java IDE ?Tool
Ans. IDE stands of Integrated Development Environment. Few Java IDE's are WSAD ( Websphhere Application Developer ) , RAD ( Rational Application Developer ) , Eclipse and Netbeans.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   ide   ide   java development   wsad   rad   eclipse   netbeans


 Q12. What ate the getter and setter methods ?
Ans. getters and setters methods are used to store and manipulate the private variables in java beans. A getters as it has name, suggest retrieves the attribute of the same name. A setters are allows you to set the values of the attributes.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java beans   getter   setter


Frequently asked in Phone Interviews.
 Q13. What the Bean scopes provided by Spring ?Spring
Ans. Singleton , Prototype , Request , Session , global-session

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring framework   bean scope   general electric   ge


 Q14. When should we use prototype scope and singleton scope for beans ?Spring
Ans. We should use singleton scope for beans when they are stateless and prototype when they are stateful.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring   bean scope   general electric   ge  singleton


 Q15. Should we have instance variables in the Spring Bean which has been scoped as Singleton ?Spring
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 :   

   Like         Discuss         Correct / Improve     java   singleton   spring framework   spring beans


 Q16. Which class provides the enumerated value for Bean Scope ?

a. BeanDefinition
b. ConfigurableBeanFactory
c. WebApplicationContext
d. All of the Above
Spring
Ans. All of the Above

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring   spring beans   spring bean scope


 Q17. What is a Java Bean ? How is it different from other Java classes ?
Ans. A Java bean is a class which abides by following conventions:

Core of the object is member elements and not operations ( methods )

Member Elements can be accessed by getters (and setters if those properties are not read-only).

serializable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java bean   javabean   pojo   classes      basic        frequent


 Q18. Which type of EJB can use bean pooling?Java EE
Ans. Stateless Session Beans

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     EJB  java beans     Asked in 1 Companies


 Q19. What is the use of @Bean annotation in Spring ?Spring
Ans. There are 2 ways to specify dependencies in Spring, one by the way of specifying beans in config files and other is by specifying annotations like @Bean, @Component , @Service etc to let spring know of the dependencies.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring bean annotation  spring annotations


 Q20. What is the difference between Elastic Compute Cloud and Elastic Beanstalk ?Amazon Web Services (AWS)
Ans. EC2 is Amazon computing service whereas Elastic Beanstalk is the AWS service for deploying and managing web applications.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Elastic Compute Cloud   EC2   Elastic Beanstalk


 Q21. How do you check logs for your application in AWS ?Amazon Web Services (AWS)
Ans. We can do it by either going to Elastic Beanstalk -> Respective instance -> Logs

or using CloudWatch -> Logs -> Respective Log Group

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     aws logs  cloudwatch logs  elastic beanstalk


 Q22. What do you understand by "Scaling Trigger" ?Server
Ans. It's a configuration for auto scaling environment that specify the attributes / conditions for scaling instances up and down. For example - We may like environment to scale up when the number of requests / sec increases a particular threshold and scale down when it decreases below a threshold.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     AWS  Amazon AWS  Amazon EC2  Elastic Beanstalk  Auto Scaling  Scaling Trigger  production support


 Q23. How can we know how many instances are currently in service within an Elastic Beanstalk environment ?Amazon Web Services (AWS)
Ans. We can go to respective environment and check configuration and then scaling. It mentions that as current status like

Current status:

2 instance(s) in service, Min: 1, Max: 4


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     AWS  Amazon AWS  Amazon EC2  Elastic Beanstalk  Auto Scaling


 Q24. Difference between ApplicationContext and BeanFactory ?Spring
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     ApplicationContext  BeanFactory   ApplicationContext vs BeanFactory        frequent


 Q25. Explain inner beans in Spring.Spring
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring  spring beans   spring inner beans


 Q26. What is a session bean ?Java EE
 This question was recently asked at 'BirlaSoft'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     session bean   java bean     Asked in 1 Companies


 Q27. What are the disadvantages of Bean Auto Wiring in Spring ?Spring
Ans. It can always be overridden with explicit wiring. Moreover it's confusing if we use both explicit as well as explicit wiring in the project.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Spring beans  auto wiring  autowiring


 Q28. Can we use Prototype Bean scope with Autowiring ?Spring
Ans. Default Bean scope in auto wiring is Singleton but Yes, that can be changed by specifying the Bean scope explicitly.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     spring boot   spring mvc  autowiring  bean scope   prototype bean scope      intermediate


 Q29. How can we take snapshots and track changes to environment variables in Elastic Beanstalk or Lambda ? Amazon Web Services (AWS)
Ans. We can use AWS Config

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     aws elastic beanstalk  amazon elastic beanstalk  aws lambda  aws serverless computing  amazon cloud serverless computing  amazon lambda


 Q30. Which type of EJB can use bean pooling?Java EE
a. Session Beans
b. Stateless Session Beans
c. Stateless Sessionless Beans
d. Any EJB Beans

Ans.b. Stateless Session Beans


Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: