Design Patterns Are Used in Hibernate Framework

Java Design Patterns Interview Questions and Answers

In this article, we will discuss the Java design patterns interview questions asked for experienced Java developers.

Let's discuss the most useful and frequently asked interview questions of Java/Java EE design patterns.

1. Can you name a few design patterns used in the standard JDK library?

Here is a list of design patterns used inJava's core libraries.

Abstract factory

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

  • javax.xml.parsers.DocumentBuilderFactory#newInstance()
  • javax.xml.transform.TransformerFactory#newInstance()
  • javax.xml.xpath.XPathFactory#newInstance()

Here is a list of a few known design patterns used in Spring Framework.

3. What are design patterns used in Hibernate Framework?

You can explain the design patterns you have been using in yours with real-time scenarios.

5. What is a Singleton design pattern in Java? write code for a thread-safe singleton in Java

6. What are the advantages of the Factory Pattern and when to use the Factory Pattern?

Advantages of the Factory Design Pattern

  • Factory Method Pattern allows the sub-classes to choose the type of objects to create.
  • It promotes the loose-coupling by eliminating the need to bind application-specific classes into the code. That means the code interacts solely with the resultant interface or abstract class so that it will work with any classes that implement that interface or that extend that abstract class.

Use the Factory Method pattern when

  • a class can't anticipate the class of objects it must create
  • a class wants its subclasses to specify the objects it creates
  • classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate

7. Name a few Object-Oriented Design Principles

  1. Encapsulate What Varies
  2. Code to an Interface Rather Than to an Implementation
  3. Delegation Principle
  4. The Open-Closed Principle (OCP)
  5. Dry- Don't Repeat Yourself
  6. Single Responsibility Principle (SRP)
  7. Liskov's Substitution Principle (LSP)
  8. Interface Segregation Principle (ISP)
  9. Dependency Injection or Inversion Principle

8. What is the use of Design Patterns?

  • Design patterns can speed up the development process by providing tested, proven development paradigms. Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems and improves code readability for coders and architects familiar with the patterns.
  • Often, people only understand how to apply certain software design techniques to certain problems. These techniques are difficult to apply to a broader range of problems. Design patterns provide general solutions, documented in a format that doesn't require specifics tied to a particular problem.
  • In addition, patterns allow developers to communicate using well-known, well-understood names for software interactions. Common design patterns can be improved over time, making them more robust than ad-hoc designs.

9. Name a few GOF design patterns?

The GoF Design Patterns are broken into three categories:

  1. Creational Patterns for the creation of objects;
  2. Structural Patterns to provide relationships between objects
  3. Behavioral Patterns to help define how objects interact.

10. Name a few Java EE desgin patterns

11. What is Singleton's design pattern and when to use it?

Definition

Ensure a class only has one instance, and provide a global point of access to it.

Use the Singleton pattern when

  • there must be exactly one instance of a class, and it must be accessible to clients from a well-known access point.
  • when the sole instance should be extensible by subclassing, and clients should be able to use an extended instance without modifying their code.

12. What is the Builder design pattern and when to use it?

Definition

Separate the construction of a complex object from its representation so that the same construction process can create different representations.

Use the Builder pattern when

  • the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled.
  • the construction process must allow different representations for the object that's constructed.

Design Patterns Interview

Free Spring Boot Tutorial - 5 Hours Full Course


Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course

Design Patterns Are Used in Hibernate Framework

Source: https://www.javaguides.net/2019/01/java-design-patterns-interview-questions-answers.html

0 Response to "Design Patterns Are Used in Hibernate Framework"

Enregistrer un commentaire

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel