I was asked in a job interview to give examples of design patterns and how they are used in the JVM implementation? I was stumped -- can anyone suggest answers so I'll know what to say if I'm ever asked again?
Asked
Active
Viewed 133 times
0
-
A very straightforward one would be the Observer Pattern with [Observable](http://docs.oracle.com/javase/7/docs/api/java/util/Observable.html). – Jeroen Vannevel Jan 29 '14 at 08:31
-
6possible duplicate of [Examples of GoF Design Patterns](http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns) – Boris the Spider Jan 29 '14 at 08:32
-
You probably mean the JDK rather than the JVM... – Boris the Spider Jan 29 '14 at 08:32
1 Answers
4
- Java
File IO
library is based onDecorator pattern
. - Java
Collections sort()
usesStrategy pattern
. - There is inbuilt support for
Observer Pattern
in JDK, By usingObservable
class andObserver
interface, you can haveObserver Pattern
Singleton Pattern
in used inRuntime
class, where you can have only one object of type 'Runtime', by accessinggetRuntime()
method.

Aman Arora
- 1,232
- 1
- 10
- 26