Design - Interview Questions and Answers for 'Inject' | 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

   



Design - Interview Questions and Answers for 'Inject' - 17 question(s) found - Order By Newest

Almost sure to be asked in every company using any Dependency Injection framework ( Spring, Guice etc )
  Q1. What is Dependency Injection or IOC ( Inversion of Control ) ?Design
Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility.

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

   Like         Discuss         Correct / Improve     design patterns   ioc ( Inversion of Control )  dependency injection     Asked in 83 Companies      intermediate        frequent


 Q2. What are the benefits of Dependency Injection or IOC ?Design
Ans. Central place for configuring dependencies.

No need to create object, container manage all this By using Run time polymorphism and association.

Facilities development of framework / libraries by injecting implementation classes in the implementation code.

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

   Like         Discuss         Correct / Improve     dependency injection  IOC  inversion of control


 Q3. What are different types of dependency injections ?Design
Ans. Setter injection
Constructor injection
Interface injection
Look-up method/method injection

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

   Like         Discuss         Correct / Improve     dependency injection   design patterns     Asked in 1 Companies


 Q4. Name few Dependency Injection frameworks ?
Ans. Google Guice , Spring , PicoContainer and Dagger.

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

   Like         Discuss         Correct / Improve     dependency injection   di   frameworks   ioc


 Q5. Why do we need polymorphism in Java ?Core Java
Ans. Frankly saying I dont see much use of method overloading as its just little design convenience as you can use the same name but still have binding to different methods depending on the need.

Method overriding is really important and is much more useful than method overloading. Along with other programming concepts like interfaces and dependency injection , it facilitates the development of software as libraries and plug-gable components.

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

   Like         Discuss         Correct / Improve     Polymorphism  dependency injection


Frequently asked in Phone Interviews.
 Q6. 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 :   

   Like         Discuss         Correct / Improve     java   spring   spring container   dependency injection   auto wiring   auto wiring types   general electric   ge


 Q7. What is the difference betweeen @Inject and @Autowired ?Spring
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 :   

   Like         Discuss         Correct / Improve     spring   web frameworks   dependency injection   autowired   inject   spring annotations   ioc


 Q8. Which of the following Java features facilitates Dependency Injection - Inheritance or Composition ?
Ans. Composition for sure. Inheritance in case the reference of a parent class is used. If its interface, no Inheritance involved.

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

   Like         Discuss         Correct / Improve     dependency injection  IOC


 Q9. What are the different ways in which dependency injection can be done using Spring Framework ?Spring
Ans. Using Constructor and Setters.

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

   Like         Discuss         Correct / Improve     spring  dependency injection   inversion of control


 Q10. Difference between constructor and setter injection ?Spring
Ans. 1. In Setter Injection, partial injection of dependencies can possible, means if we have 3 dependencies like int, string, long, then its not necessary to inject all values if we use setter injection. If you are not inject it will takes default values for those primitives1. In constructor injection, partial injection of dependencies cannot possible, because for calling constructor we must pass all the arguments right, if not so we may get error

2. Setter Injection will overrides the constructor injection value, provided if we write setter and constructor injection for the same property [i already told regarding this, hope you remember ] But, constructor injection cannot overrides the setter injected values

3. If we have more dependencies for example 15 to 20 are there in our bean class then, in this case setter injection is not recommended as we need to write almost 20 setters right, bean length will increase. In this case, Constructor injection is highly recommended, as we can inject all the dependencies with in 3 to 4 lines [i mean, by calling one constructor]

4. Setter injection makes bean class object as mutable [We can change ] .Constructor injection makes bean class object as immutable [We cannot change ]

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

   Like         Discuss         Correct / Improve     spring  dependency injection   inversion of control     Asked in 3 Companies


 Q11. Which of the OOP's features facilitate dependency injection ? Design
Ans. Inheritance , Runtime Polymorphism and Composition.

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

   Like         Discuss         Correct / Improve     dependency injection  inversion of control  ioc  oops  oops features


 Q12. Is dependency injection possible if we don't have inheritance / Composition ?Design
Ans. Without composition - No, as it's the core of dependency injection.

With Inheritance - Yes, through interface implementation.

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

   Like         Discuss         Correct / Improve     dependency injection  inversion of control  ioc


 Q13. What could be the driving force to have dependencies injected through class than through config file while using IOC or Dependency Injection ? Design
Ans. Unit Testing

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

   Like         Discuss         Correct / Improve     dependency injection  inversion of control


 Q14. Tell something about Dependency Injection and it's drawbacks. In which situation, you may not like to use dependency injection ?Design
 This question was recently asked at 'Bloomberg'.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     dependency injection     Asked in 1 Companies


 Q15. What is setter injection ?Spring
Ans. Setter Injection in Spring is a type of dependency injection in which the framework injects the dependent objects into the client using a setter method.

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

   Like         Discuss         Correct / Improve     setter injection   dependency injection     Asked in 2 Companies


 Q16. In which way are you using dependency injection in Spring ? Annotation , Config or Class ?Spring
Ans. Possible Answer - We are using config file.

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

   Like         Discuss         Correct / Improve     Dependency injection     Asked in 1 Companies


 Q17. How dependency injection in angular helps with loose coupling in angular ?Angular
 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     Dependency injection



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: