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 Newest

   next 30
Frequently asked Design Pattern interview question.
 Q61. What is a prototype design pattern ?Design
Ans. The prototype pattern is a creational design pattern. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. Prototype is used when we need duplicate copies of objects.

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

   Like         Discuss         Correct / Improve     design pattern  prototype design pattern  cloning     Asked in 11 Companies      intermediate


 Q62. What are the advantages disadvantages of keeping config entries in database instead of property file and vice versa ?Design
Ans. Entries in DB will be retrieved at runtime unless a cache is maintained in application. Entries in File will be loaded to memory by default. Both can be implemented in 1 manner or other. By default property file will take space in memory, will be faster, and will require application restart on change. By Default DB config will be pulled at runtime, will be little slower, and doesn't require an application restart.

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

   Like         Discuss         Correct / Improve     design


 Q63. Have you ever felt the need of keeping the constructor private ?Design
Ans. Yes, When either we don't want an object to be created ( class having all static elements and hence not required ) or object to be created using a static method or static block. One such example could be a situation when we would like app to load objects at start up and we would like to restrict new object creation by any request.

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

   Like         Discuss         Correct / Improve     private constructor  constructor


 Q64. Is it a Good practice to have application decision making in DAOs ?Design
Ans. No, DAO's should only have methods to perform CRUD operations. Application logic should reside in service methods.

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

   Like         Discuss         Correct / Improve     A


 Q65. Can you please provide an implementation of application level cache ?Design
Ans. We can use an expiration map whose entries gets expired after a certain interval and then we can put the logic to retrieve the entries if its expired in map. Alternatively we can create a separate class and make map its element. We can refresh the map in this class periodically by using a monitoring thread within static block.

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

   Like         Discuss         Correct / Improve     


 Q66. What is a responsive web design ?Design
Ans. Responsive web design is a approach to web design that allow desktop webpages to be viewed perfectly in different devices and sizes.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q67. Design an online shopping site system ?Design
Ans. AWS Services - CloudFront for distribution / caching, EC2 for computing, EBS for block storage , S3 for object storage , RDS for database , Kinesis for streaming , CloudWatch for monitoring.

Technologies - Java for back end with Spring Boot , Angular , RxJs for front end .

Architecture - Service Oriented. Multi layer.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q68. Implement an LRU Cache ?Design
Ans. https://www.programcreek.com/2013/03/leetcode-lru-cache-java/

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q69. How to make sure that only one instance is created in Singleton Pattern ?Core Java
Ans. public class SingleTon {
private SingleTon() {
if (singleTon != null) {
throw new RuntimeException("cant not create the object");
}
}
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("can not be create");
}

static private volatile SingleTon singleTon;
public static SingleTon getInstance() {
SingleTon singleTon = this.sample;
if (singleTon == null) {
synchronized (this) {
singleTon = this.singleTon;
if (singleTon == null) {
singleTon = this.singleton = new SingleTon();
}
}
}
return singleTon;
}
}

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

   Like         Discuss         Correct / Improve     singleton  design pattern     Asked in 2 Companies


 Q70. What is a factory design pattern ?Design
Ans. Factory Design Patterns is the pattern that recommends creation of separate Factory Object for creation of other object.

So its like saying - If you want to create an object of ClassA, Talk to FactoryObject ( which is an object of FactoryClass ). FactoryObject in itself encapsulates the inputs and logic required to make the decision regarding the creation and construction of object.

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

   Like         Discuss         Correct / Improve     design pattern  factory design pattern     Asked in 9 Companies


 Q71. Write a program to print two digit numbers that fulfil following criteria

Summing their digits and then multiplying with 3 should result in the number

For ex - 27 , (2+7) * 3 = 27


Core Java
Ans. public class BuggyBread {
   public static void main(String args[]) {
      for(int x=10;x<100;x++){
         int tensDigit = x/10;
         int unitDigit = x%10;
         
         if((tensDigit+unitDigit)*3 == x){
            System.out.println(x);
         }
      }
   }
}

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q72. Difference between Singleton and Factory Design Pattern ?Design
Ans. Both are creational design patterns but singleton facilitates in creation and reuse of single object whereas Factory deals with creation of multiple objects.

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

   Like         Discuss         Correct / Improve     Design pattern  singleton  factory  singleton vs factory     Asked in 4 Companies


 Q73. Design a Passport Office systemDesign
 This question was recently asked at 'Netcracker Technology'.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     Asked in 1 Companies


 Q74. Name few creational design patterns ?Design
Ans. Factory,Abstract Factory,Singleton,Prototype and Builder

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

   Like         Discuss         Correct / Improve     Design Pattrns  Creational Design Patterns      Intermediate


 Q75. Name few structural Design Patterns ?Design
Ans. Adapter,Bridge,Composite,Decorator,Facade,Flyweight,Proxy

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

   Like         Discuss         Correct / Improve     Design Patterns  Structural Design Patterns      Intermediate


 Q76. Name few Behavioral Design Patterns ?Design
Ans. Interpreter,Chain of Responsibility,Command,Iterator,Observer,Mediator,Memento

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

   Like         Discuss         Correct / Improve     Behavioral Design Patterns      Intermediate


 Q77. Which is your favorite Design pattern, each in Creational , Structural and Behavioral and Why ?Design
Ans. [Open Ended Answer]

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

   Like         Discuss         Correct / Improve     Design Patterns      Intermediate


 Q78. Is it a good Design practice to call methods from a constructor ?Design
Ans. Constructor's objective is to initialize member elements. If we don't deviate from that and don't have methods with logic in them, I don't see an issue with constructor's calling other methods assuming the methods are doing nothing but initialization. There are situations wherein we classify the member elements based on their type and hence having different initialization methods for different element types will give a better abstracted way to initialize them.

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

   Like         Discuss         Correct / Improve     design constructor


 Q79. Is it a good design practice to have programming constructs like if and loops in constructor ?Design
Ans. I would avoid that. If we need to initialize member elements differently on the basis of some condition, I would prefer having overloaded constructors. I don't see a need to have a loop for initializing member elements unless the count of elements is huge and they all need to be initialized with common value.

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

   Like         Discuss         Correct / Improve     design constructor  for loop


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


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


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


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


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


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


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


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


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


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


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


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: