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 IOlibrary is based onDecorator pattern. - Java
Collections sort()usesStrategy pattern. - There is inbuilt support for
Observer Patternin JDK, By usingObservableclass andObserverinterface, you can haveObserver Pattern Singleton Patternin used inRuntimeclass, where you can have only one object of type 'Runtime', by accessinggetRuntime()method.
Aman Arora
- 1,232
- 1
- 10
- 26