Interview Questions and Answers for 'Design' | 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 - Order By Rating

   next 30
 Q91. Can you explain software design principles cohesion and coupling with an example?Design
 This question was recently asked at 'Fidelity Information Services (FIS)'.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     cohesion  coupling     Asked in 1 Companies        frequent


 Q92. What is monkey patching ?Design
Ans. The term monkey patch only refers to dynamic modifications of a class or module at runtime, motivated by the intent to patch existing third-party code as a workaround to a bug or feature which does not act as desired.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q93. Design a Database Schema to store Employee Information with each employee having multiple addresses. Database
Ans. We can have 2 entities i.e EMPLOYEE and ADDRESS and can have a relationship Table , EMPLOYEE_ADDRESS having one to may relationship between the two.

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

   Like         Discuss         Correct / Improve     database schema   design     Asked in 2 Companies


 Q94. 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


 Q95. How do you design microservices?Design
 This question was recently asked at 'Citigroup Bank,Sofi'.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     microservices     Asked in 2 Companies


 Q96. 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


 Q97. 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


 Q98. Let's suppose we have an to destroy objects, Design a program to implement garbage collection ?Design
Ans. Step 1 - We can create a Registry Class having Map of all created objects as key and References list as value.

Step 2 - Whenever we create an object , we should update the Registry in the constructor to add the new object.

Step 3 - Whenever we assign a new reference to the object , we need to update the entry in Map. Similarly if the reference get's removed ( end of scope etc ), we need to remove the entry of reference from the list.

Step 4 - We can have threaded code to monitor the Map to see if any object looses all it's references and should call the method to destroy object and clean the memory.

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

   Like         Discuss         Correct / Improve     garbage collection


 Q99. How can we track of all objects created in an application ?Design
Ans. We can store the references in a collection by adding to those objects in the collection. We can create a class "ObjectRegistry" with a collection or multiple collections with a search algorithm to look for the already collected objects.

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

   Like         Discuss         Correct / Improve     objects


 Q100. If you need to consume messages from the queue faster, which approach will you recommend - batching or concurrency ?Design
Ans. Each has it's own advantages

Batching requires less resources but may result in loosing whole batch in case of failure whereas concurrency even though is little more expensive in terms of resources but would result in minimal loss in case of failure.

In case messages are to be consumed in a particular order, batching them in that order and then consuming them makes better sense.

if incoming messages are not continuous , it makes more sense to do concurrency as we need not wait for all messages to form a batch and flush. Though time sensitivity can be added but that would add unnecessary complexity.

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

   Like         Discuss         Correct / Improve     concurrency vs batching   concurrency  multithreading  batch


 Q101. What are the worst anti patterns in Java ?Design
 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     antipattern  anti pattern


 Q102. Design a class diagram for a farm.Design
 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     class diagram   design


 Q103. 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


 Q104. Give an example of how Object Oriented Programming Concepts can be implemented.Design
Ans. You can implement encapsulation in Java by keeping the fields (class variables) private and providing public getter and setter methods to each of them. Java Beans are examples of fully encapsulated classes. Encapsulation in Java: Restricts direct access to data members (fields) of a class.

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

   Like         Discuss         Correct / Improve     oops  oops example  oops concepts  oops features     Asked in 2 Companies      basic        frequent


 Q105. Design a Coffee machine using Oops concepts.Design
 This question was recently asked at 'ECI Telecom'.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     design  design a coffee machine     Asked in 1 Companies


 Q106. What are the trade offs between public constructor and static final method ?Core Java
Ans. Public constructor is simple and easy as it's the default way of object creation. So there are no additional coding overheads as compiler provides the default constructor if none is provided by coder.

With static final methods, it facilitates loose coupling by segregating the responsibility of object creation to a separate method. Validation can be done on the constructor arguments before calling it. Moreover if any adaption on the arguments is required that can achieved easily with factory method.On the flip side, there is coding overhead and additional method call.

  Sample Code for constructor

  Sample Code for factory

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

   Like         Discuss         Correct / Improve     constructor  factory design pattern  factory method


 Q107. What could be the real world example of Adapter Design Pattern ?Design
Ans. Voltage converters / Power Adapters

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

   Like         Discuss         Correct / Improve     Adapter Design Pattern  Design Pattern


 Q108. What are the disadvantages of Adapter Design Pattern ?Design
Ans. It introduces a layer of adaptations before it reaches the final and desired interface.

Moreover sometimes all requests are forwarded to adapter class. Some of such requests doesn't even require any sort of adaptions as they are qualified to call the final interface directly and introducing overheads.

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

   Like         Discuss         Correct / Improve     Adapter Design Pattern  design pattern


 Q109. What are some uses of interceptors ?Java EE
Ans. Authentication / Authorization
URL forwarding
Auditing / Logging
Localization

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

   Like         Discuss         Correct / Improve     interceptors  interceptor design pattern


 Q110. Explain Interceptor Design Pattern ?Design
Ans. It is used for intercepting the request. It's primary use is to implement security policy. All or specific request types can be intercepted and hence forwarded to authentication / authorization module so as to facilitate authorized requests to application.

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

   Like         Discuss         Correct / Improve     interceptors  interceptor design pattern


 Q111. Can you give an example of "Convention over configuration" Design principle ?Design
Ans. Hibernate mapping configurations are used for mapping hibernate entities and corresponding DB Tables. Conventionally Entities and Table can share the same name and hence framework can provide implicit mapping instead of explicit mapping through configurations. Though it may result in little loss of flexibility in extreme cases but will work with all applications following the convention.

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

   Like         Discuss         Correct / Improve     Convention over configuration


 Q112. Are there any disadvantages of "Convention over configuration" Design paradigm ?Design
Ans. Yes, It may result in some loss of flexibility as the application has to follow all conventions. Moreover it can contradict with other design paradigms or principles used in the application or framework.

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

   Like         Discuss         Correct / Improve     Convention over configuration


 Q113. What is "convention over configuration" ? Which framework uses this design paradigm ?Design
Ans. Convention over configuration is a way of software design used by frameworks that attempt to decrease the number of decisions that a developer is required to make without necessarily losing flexibility. The objective is to reduce the unnecessary configurations and follow conventions to accomplish that. For example - DB Entity and DB Table name conventionally should be same and hence shouldn't require configuring mapping between the two.

"Spring Boot" and "Ruby on Rails" have adopted this design principle.

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

   Like         Discuss         Correct / Improve     Convention over configuration     Asked in 1 Companies


 Q114. Create an object oriented design using classes and interfaces to show relationship in a Sport tournament ?Design
 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     


 Q115. How can we prevent duplicate object creation in Java?Design
 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     


 Q116. How do you prefer to keep names for classes and interfaces ?Design
Ans. I like to keep the names in Capital Camel case. Moreover I prefer to keep the names for classes, enums and interfaces such that they are easily distinguishable just by the pattern of their names.

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

   Like         Discuss         Correct / Improve     naming convention


 Q117. Is it a good practice to override static methods ?Design
Ans. Though it's useful but it's not as useful as overriding member or object methods. We cannot achieve polymorphic behavior with static methods by overriding their definition in derived class.

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

   Like         Discuss         Correct / Improve     override static methods


 Q118. What should be the intended sequence in which elements and methods should be declared in a class ?Design
Ans. static final variables
public variables ( though it should be avoided )
private variables
constructor
public methods
private methods.

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

   Like         Discuss         Correct / Improve     


 Q119. Why it's a good practice to expose member elements through getter methods ?Design
Ans. Encapsulation and Polymorphism.

We need methods to access variables in a polymorphic way as overriding only happens with methods and not with variables. Moreover getter provides a way to minimally open the access window for the object and hence provides better encapsulation. To add to those, we can have validation in the getter method before returning elements.

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

   Like         Discuss         Correct / Improve     encapsulation


 Q120. Which are the most commonly used Design Patterns ?Design
Ans. Builder ( While Writing Unit Tests )
Prototype ( Cloning )
Adapter ( asList , toString )
Chain Of Responsibility ( Logging )
Singleton
Factory ( Action Mapping )
Proxy
Observer ( Event Listener )
MVC ( Web frameworks )
Filter ( Criteria )

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

   Like         Discuss         Correct / Improve     Design Patterns  widely used Design patterns      intermediate        frequent

Try 1 Question(s) Test


previous 30   next 30

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: