Design Pattern Used In JDK

Connect with

Design Pattern Used In JDKLearn what all design pattern used in JDK Java. creational design pattern in JDK, behavioral design pattern in JDK.

1. Overview of Design Pattern Used In JDK

In java, a lot of question has been asked in all the level specially for mid-management to senior management, there are a lot of questions arises while interview process. A few of them are very important e.g. what are the design patterns you used in the current project? what are the design patterns you know and which one you used and why? for solving what problem you used this? etc… You can find out a lot of pages on the internet, but I tried to recall those gist in one page.

2. Creational Design Patterns in JDK

Singleton : ensure only one instance of a class is created and provide a global access point to that object.

Used in jdk:

  • java.lang.Runtime#getRuntime()
  • java.awt.Desktop#getDesktop()
  • java.lang.System#getSecurityManager()

Factory pattern in JDK

Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.

Used in jdk:

  • java.lang.Class#newInstance()
  • java.lang.Integer#valueOf(String) (also on Boolean, Byte, Character, Short, Long, Float and Double)
  • java.lang.Class#forName()
  • java.lang.reflect.Array#newInstance()
  • java.lang.reflect.Constructor#newInstance()
  • java.lang.Object#toString() (overrideable in all sub-classes)

Connect with

Leave a Comment

Your email address will not be published. Required fields are marked *