Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

TOP 10 Interview Answers: Design Patterns Questions &

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

TOP 10

DESIGN PATTERNS
INTERVIEW
QUESTIONS &
ANSWERS
Q1.

WHAT ARE SOLID


PRINCIPLES?
• A set of guidelines that helps developers
to make a good software system design.
• SOLID is a combination of five fundamental
designing principles:

S ingle Responsibility Principle (SRP)


O pen/Closed Principle (OCP)
L iskov Substitution Principle (LSP)
I nterface Segregation Principle (ISP)
D ependency Inversion Principle (DIP)
Q2.

WHAT IS SINGLETON
PATTERN?
Ensures that a class has only one instance
and provides a global point of access to it.

EXAMPLES
Need a single instance of an object
throughout the application
• Exception Logging
• Database Manager
• Business Layer Manager
Q3.

WHAT IS FACTORY
PATTERN?
Allow us to create object without exposing
the creation logic.

EXAMPLES

Need to create different logger types


like Console Logger, Database
Logger and File Logger etc.
Need to create different report types
like PDF and Word etc.
Q4.

WHAT IS BUILDER
PATTERN?
Used to build a complex object by using a
step by step approach. Builder interface
defines the steps to build the final object.

EXAMPLES

Construct Report/Email Builder Class


• Set Header
• Set Body
• Set Footer
Q5.

WHAT IS ADAPTER
PATTERN?
Acts as a bridge between two incompatible
interfaces.
EXAMPLES

Need to convert third party objects to


application types
Ado.Net SqlAdapter, OracleAdapter,
MySqlAdapter
Q6.

WHAT IS FACADE
PATTERN?
Hides the complexities of the system and a
higher-level interface that makes the
subsystem easier to use.

EXAMPLES

• User Registration Process


• Process An Order
• Creating User Follower Workflow
Q7.

WHAT IS BRIDGE
PATTERN?
Separate abstraction from its implementation
so that both can be modified independently.
Involves an interface that acts as a bridge
between the abstraction & implementation.
EXAMPLES
In Payment using Credit Card & Debit
Card but in future add more like UPI.
In Messaging using SMS and Email but in
future add more like WhatsApp.
Q8.

WHAT IS COMMAND
PATTERN?
A request is wrapped under an object as a
command and passed to the invoker object.
Further invoker object passes the command
to the appropriate object to handle it.

EXAMPLES

Menu systems in Editor, IDE like apps.


Auditing & logging of all changes via
commands.
Q9.

WHAT IS STATE
PATTERN?
Allows an object to alter its behavior when
its internal state changes.

EXAMPLES

Task States: ToDo, Doing, Done


Validation States: Invalid, Valid
A Machine (Printer) States: Ready,
Printing, Done
Q10.

WHAT IS OBSERVER
PATTERN?
Allows a single object to publish its state
changes to other observer objects that
depend upon it.

EXAMPLES

Send notification about state change


to Followers and Subscribers.
WANT TO GET A
HIGH-PAYING JOB
AS A DEVELOPER?
CONTACT US

+91-9999 123 502

hello@scholarhat.com

www.scholarhat.com

You might also like