|
1 |
| -## Java Design Pattern Questions and Answers |
2 |
| - |
3 |
| - |
| 1 | +# Java Design Pattern Questions and Answers |
4 | 2 |
|
5 | 3 | #### Q. Exaplain MVC, Front-Controller, DAO, DTO, Service-Locator, Prototype design patterns?
|
6 |
| -*TODO* |
7 | 4 |
|
8 |
| -#### Q. What are the design patterns available in Java? |
| 5 | +*ToDo* |
| 6 | + |
| 7 | +## Q. What are the design patterns available in Java? |
9 | 8 | Java Design Patterns are divided into three categories – creational, structural, and behavioral design patterns.
|
10 | 9 |
|
11 | 10 | **1. Creational Design Patterns**
|
@@ -42,7 +41,7 @@ Java Design Patterns are divided into three categories – creational, structura
|
42 | 41 | * Dependency Injection Pattern
|
43 | 42 | * MVC Pattern
|
44 | 43 |
|
45 |
| -#### Q. Explain Singleton Design Pattern in Java? |
| 44 | +## Q. Explain Singleton Design Pattern in Java? |
46 | 45 | **1. Eager initialization:**
|
47 | 46 | In eager initialization, the instance of Singleton Class is created at the time of class loading.
|
48 | 47 |
|
@@ -149,7 +148,7 @@ public class BillPughSingleton {
|
149 | 148 | <b><a href="#">↥ back to top</a></b>
|
150 | 149 | </div>
|
151 | 150 |
|
152 |
| -#### Q. Explain Adapter Design Pattern in Java? |
| 151 | +## Q. Explain Adapter Design Pattern in Java? |
153 | 152 | Adapter design pattern is one of the structural design pattern and its used so that two unrelated interfaces can work together. The object that joins these unrelated interface is called an Adapter.
|
154 | 153 |
|
155 | 154 | Example:
|
@@ -232,7 +231,7 @@ public class Main {
|
232 | 231 | <b><a href="#">↥ back to top</a></b>
|
233 | 232 | </div>
|
234 | 233 |
|
235 |
| -#### Q. Explain Factory Design Pattern in Java? |
| 234 | +## Q. Explain Factory Design Pattern in Java? |
236 | 235 | A Factory Pattern or Factory Method Pattern says that just define an interface or abstract class for creating an object but let the subclasses decide which class to instantiate. In other words, subclasses are responsible to create the instance of the class.
|
237 | 236 |
|
238 | 237 | Example: Calculate Electricity Bill
|
@@ -330,7 +329,7 @@ class GenerateBill {
|
330 | 329 | <b><a href="#">↥ back to top</a></b>
|
331 | 330 | </div>
|
332 | 331 |
|
333 |
| -#### Q. Explain Strategy Design Pattern in Java? |
| 332 | +## Q. Explain Strategy Design Pattern in Java? |
334 | 333 | Strategy design pattern is one of the behavioral design pattern. Strategy pattern is used when we have multiple algorithm for a specific task and client decides the actual implementation to be used at runtime.
|
335 | 334 |
|
336 | 335 | Example: Simple Shopping Cart where we have two payment strategies – using Credit Card or using PayPal.
|
|
0 commit comments