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

   



Interview Questions and Answers for 'Strategy' - 5 question(s) found - Order By Newest

 Q1. Difference between Factory and Strategy Design Pattern ?Design
Ans. Factory is a creational design pattern whereas Strategy is behavioral design pattern. Factory revolves around the creation of object at runtime whereas Strategy or Policy revolves around the decision at runtime.

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

   Like         Discuss         Correct / Improve     java   design pattern   factory   strategy   creational design pattern   behavioral design pattern     Asked in 1 Companies      expert


 Q2. If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?

1. Insert into the DB Table. If exception occurs, update the existing record.
2. Check if the record exists and update it if it exists, If not insert a new record.
Solution
Ans. In first case, there would be 2 DB calls in worst case and 1 in best case. In 2nd approach there will be always 2 DB calls.

Decision on the approach should depend on the following considerations -

1. How costly is the call to DB ? Are we using indices , hibernate etc

If calls to DB are costly , 1st approach should be the choice.

2. Exception Book keeping load upon exception.

The benefit of saving 1st call in approach 1 should be bigger than the Book keeping for the exception.

3. Probability of the exception in first apparoach.

If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception.

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

   Like         Discuss         Correct / Improve     database   insert-update   db exceution plan   db strategy   design   architecture   technical lead


 Q3. Shall we use abstract classes or Interfaces in Policy / Strategy Design Pattern ?
Ans. Strategy deals only with decision making at runtime so Interfaces should be used.

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

   Like         Discuss         Correct / Improve     java   design pattern   strategy design patterm      expert


 Q4. Which change detection strategy do you use in your application and Why ?Angular
Ans. We use ChangeDetectionStrategy.Push

As the application grows bigger , The default change detection strategy could become a performance overhead and hence should be avoided.

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

   Like         Discuss         Correct / Improve     ChangeDetectionStrategy     Asked in 1 Companies


 Q5. What are the different conditions that triggers view update in case of push ChangeDetectionStrategy ?Angular
Ans. 1. Any change in Input
2. Any even originating from the component or it's child components
3. Explicit trigger

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

   Like         Discuss         Correct / Improve     ChangeDetectionStrategy



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: