Fresh Java Patterns Interview Questions & Answers:
1. State all the different patterns and give the various divisions present?
There are various different patterns and they can be divided into these patterns they are: -
► Fundamental design patterns
► Creational patterns
► Partitioning patterns
► Structural patterns
► Behavioral patterns
► Concurrency patterns
Delegation, Interface, Immutable, Proxy and marker interface are some of the sub divisions present in Fundamental interface.
2. Explain about Template method?
Template method is the most common way of representing. Implementation of a method differs for files, sockets, pipes, strings, text entry widgets, etc. When template method is used logic of the entire class is modified. Missing logic can be called by abstract and concrete methods.
They are mostly used as concurrency control constructs. They adhere and support Sync interface and conform to acquire release protocol. It adheres to a set of permits initialized in a constructor. A semaphore can also be described on the basis of a metaphor.
Lock is known to be the safest and the basic message control mechanism used in object oriented mechanism. This is used to block the usage of methods while another method is in progress. The only safest way to use lock mechanism is to fully synchronized objects.
5. Explain about fully synchronized objects?
In a fully synchronized object all methods are synchronized. Encapsulation violations are generally neglected. Methods are finite which release locks. Even in the presence of exceptions state of the object is at the beginning and end of each method.
6. Explain about open systems?
Open systems are used widely by developers than the closed systems because these are attainable and achievable. It can be accessed across several dimensions. Full static analysis is not possible because of their nature and structural evolution which varies according to time. Opensystems may load classes dynamically, can employ call backs, resource sharing, etc.
7. Explain about closed subsystems?
In a closed system a developer will have a perfect knowledge about all the possible behaviors and static design time. By employing encapsulation techniques one can close parts of the system. This is possible in product level components and the lower rung of individual classes.
8. Explain about particle canvas?
Particle canvas is a sub class of java.awt. Canvas this class provides a drawing area for all the particles. Whenever a paint method is called it invokes draw for all the existing particles. It cannot create object or particles by itself. Existingparticle objects are stored in the array of instance variable particles.
9. Explain about state dependence?
State dependence tells you about the action performed on the object whether succeeded or failed, action which can be performed, monitoring methods, postponing, triggering, preventing, etc. This is also used to monitor methods.
10. State the purpose of why a Java singleton should be used?
Java singleton is used when a constructor and finalize methods are used only once during the lifetime of the application. If a class is referenced from within then it is garbage collected by the Java which can be retrieved if called again but the problem comes when the constructor or finalize methods are used only once.
https://InterviewQuestionsAnswers.ORG.