what are design patterns in java?give with example?

Answers were Sorted based on User's Feedback



what are design patterns in java?give with example?..

Answer / bujji

singleton,front controller,application controller,DTO

Is This Answer Correct ?    3 Yes 0 No

what are design patterns in java?give with example?..

Answer / rahul

A design pattern offers guidelines on when, how, and why an
implementation can be created to solve a general problem in
a particular context

A few well-known uses are:-
Singleton: Java AWT’s (GUI builder) Toolkit class
Proxy: CORBA’s (middleware) proxy and real objects
Chain of Responsibility: Tomcat’s (application server)
request handlers

Examples of Design Patterns:-
GoF Creational Patterns
Abstract Factory:Sets of methods to make various objects.
Builder :Make and return one object various ways.
Factory Method :Methods to make and return components of one
object various ways.
Prototype :Make new objects by cloning the objects which you
set as prototypes.
Singleton :A class distributes the only instance of itself.

GoF Structural Patterns
Adapter A class extends another class, takes in an object,
and makes the taken object behave like the extended class.
Bridge An abstraction and implementation are in different
class hierarchies.
Composite Assemble groups of objects with the same signature.
Decorator One class takes in another class, both of which
extend the same abstract class, and adds functionality.
Facade One class has a method that performs a complex
process calling several other classes.
Flyweight The reusable and variable parts of a class are
broken into two classes to save resources.
Proxy One class controls the creation of and access to
objects in another class.

GoF Behavorial Patterns
Chain Of Responsibility A method called in one class can
move up a hierarchy to find an object that can properly
execute the method.
Command :An object encapsulates everything needed to execute
a method in another object.
Interpreter Define a macro language and syntax, parsing
input into objects which perform the correct opertaions.
Iterator :One object can traverse the elements of another
object.
Mediator :An object distributes communication between two or
more objects.
Memento :One object stores another objects state.
Observer:An object notifies other object(s) if it changes.
State An object appears to change its` class when the class
it passes calls through to switches itself for a related class.
Strategy :An object controls which of a family of methods is
called. Each method is in its` own class that extends a
common base class.
Template:An abstract class defines various methods, and has
one non-overridden method which calls the various methods.
Visitor :One or more related classes have the same method,
which calls a method specific for themselves in another class.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Advanced Java Interview Questions

Why do I get a duplicate name error when loading a jar file?

0 Answers  


What is the difference between RMI and Corba?

0 Answers   Infotech,


what is Bootstrap loader program?

1 Answers   Rossell Techsys,


what is the Remote Stub?

1 Answers  


How we set Bean Id when we are creating web application using SpringMVC and Hibernet Integration

1 Answers  






Hi I have joined java course. I also want additional help from any tutorials website. Please suggest me tutorials which provides easy to understand online applet tutorials?

0 Answers  


What are the types of scaling?

0 Answers  


How to deploy Jar, War files in J2EE?

0 Answers   HCL,


What is Bootstrapping in RMI?

1 Answers  


What is the form of storage space in java?

0 Answers  


difference between HashMap, Hashset and hashTable?

2 Answers   HCL, Infotech,


What are the services in RMI ?

0 Answers  


Categories