Search Interview Questions | Click here and help us by providing the answer. Click Correct / Improve and please let us know. |
|
|||
|
| ||||
| Interview Questions and Answers for 'Raybiz' - 2 question(s) found - Order By Rating | ||||
| ||||
| Ans. Anonymous classes are defined in the new expression itself, so you cannot create multiple objects of an anonymous class. You cannot explicitly extend a class or explicitly implement interfaces when defining an anonymous class. An anonymous inner class is always created as part of a statement; don't forget to close the statement after the class definition with a curly brace. This is a rare case in Java, a curly brace followed by a semicolon. Anonymous inner classes have no name, and their type must be either a subclass of the named type or an implementer of the named interface | ||||
| ||||
| Ans. http://www.buggybread.com/2014/03/java-design-pattern-singleton-interview.html | ||||
//Double Checked Locking Code public static Singleton createInstance() { if(singleton == null){ synchronized(Singleton.class) { if(singleton == null) { singleton = new Singleton(); } } } return singleton; } //Single checked locking code public static Singleton createInstance() { synchronized(Singleton.class) { if(singleton == null) { singleton = new Singleton(); } } return singleton; } | ||||