Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Design - Interview Questions and Answers for 'Epam' - 8 question(s) found - Order By Newest | ||||
![]() | ||||
| ||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory. x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object. Sample code: String x = new String("str"); String y = new String("str"); System.out.println(x == y); // prints false System.out.println(x.equals(y)); // prints true | ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. Builder pattern is the extension of Factory pattern wherein the Builder class builds a complex object in multiple steps. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Coupling is the degree of interdependence between software modules, a measure of how closely connected two modules are or the strength of the relationships between modules. Cohesion refers to the degree to which the elements of a module belong together. Cohesion measures the strength of relationship between pieces of functionality within a given module. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Both are creational design patterns. Singleton is used when we would like to reuse an object if object is not supposed to hold request or thread specific information. Inversely Prototype is used in situations where we would like to reuse the object information but the request / thread may require it own data to be persisted. In short, Singleton is used in situations where we can live with single object being shared across multiple requests or threads whereas Prototype is used when we need duplicate copies of objects. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. http://www.buggybread.com/2014/03/java-design-pattern-singleton-interview.html | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. public class SingleTon { private SingleTon() { if (singleTon != null) { throw new RuntimeException("cant not create the object"); } } public Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException("can not be create"); } static private volatile SingleTon singleTon; public static SingleTon getInstance() { SingleTon singleTon = this.sample; if (singleTon == null) { synchronized (this) { singleTon = this.singleTon; if (singleTon == null) { singleTon = this.singleton = new SingleTon(); } } } return singleTon; } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Factory Design Patterns is the pattern that recommends creation of separate Factory Object for creation of other object. So its like saying - If you want to create an object of ClassA, Talk to FactoryObject ( which is an object of FactoryClass ). FactoryObject in itself encapsulates the inputs and logic required to make the decision regarding the creation and construction of object. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. If we don't have double checked locking, it can be broken easily through multi threaded access. Through Reflection. If multiple class loaders are loading the class. If the class is serializable or cloneable. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||