According to the Bureau of Labor Statistics (BLS), the median annual salary for software developers like J2EE developers is $101,790.The BLS has predicted a job growth rate of 31 percent through 2026, which is much faster than average for all occupations. Demand for developers will grow with the increased demand for computer software.
Prepare with the top 10 Java/J2EE Design Patterns Interview Questions highly asked in job interviews. These questions are picked from the book, Java/J2EE Design Patterns Interview Questions You’ll Most Likely Be Asked
1: What does the JTable class do in Design Patterns?
The JTable class is used to handle almost every aspect of displaying a table, but cannot know in advance what data the developer wishes to present; it is a main setter for the use of the Adapter.
2: What does the getStepCount() Method do in Design Patterns?
This Method is used as an operation in the Process Component class to count the number of steps needed in a process flow; it has to count each step only once and to not enter an infinite loop when a process contains a cycle.
3: What is an Abstraction in Design Patterns?
Abstraction is an oops concept where necessary details are hidden from the user, and only relevant details are exposed to the user. It helps in designing a solution to the problem during the design phase. Abstraction can be achieved by an interface or an abstract class. The abstract class consists of abstract methods without providing the concrete implementations for the abstract methods. It can also consist of non-abstract methods with core implementation. While interface only consists of abstract methods without their implementation.
4: What does the Monitor Function do in Design Patterns?
The Monitor Function is a way of designing an application object so that it does not produce unpredictable results when more than one thread tries to access the object at the same time.
5: What are the differences between factory and abstract factory Pattern?
Both Factory and Abstract Factory are creational design patterns. However, there are some differences between the two:
a) Factory method design pattern can be implemented by a method; the abstract factory design pattern needs to be implemented via a class
b) In the factory method pattern, we define an interface but decide which class to use at runtime. In the abstract factory method, we define interfaces corresponding to the factory classes and decide which factory class to use at runtime.
c) The abstract factory design pattern provides a higher level of abstraction as compared to the factory method
d) The factory method pattern uses inheritance whereas the Abstract Factory pattern uses Composition
6: What is the main advantage of the Facade Pattern?
The Facade Pattern helps in hiding the complexities of the application beneath the layer of an interface. This interface helps in reducing the dependency of the client classes on the subsystem classes, thus resulting in a manageable and user-friendly subsystem.
7: What happens with the response to the request in the case of these two patterns?
In the case of Proxy Pattern, the response to the request is guaranteed, provided the communication between the client and the server locations is working.
In the case of Chain of Responsibility, the response is not guaranteed. It means that the request may end up reaching the end of the chain and still might not be processed.
8: What problem does the Business Delegate Pattern try to solve?
When the presentation tier or client application accesses the business tier directly, the business service API is exposed to the client application or presentation tier. So if the business API changes, the corresponding changes will have to be made in the presentation tier. Also, in such an implementation, there is a performance issue as well, since the business service is invoked each time by the client application. Thirdly, this kind of implementation causes a tight coupling between the presentation tier and the business tier. The business delegate pattern solves all these problems. The Business Delegate class is present on the client side and it hides the implementation details of the business tier by providing an abstraction. So the client application only interacts with the delegate class which in turn routes the client’s request to the appropriate business method.
9: How are new Observers added to existing ones?
This is achieved after applying the Observer Pattern and adding them dynamically without requiring any changes to the Subject Class. Also, Observers remain unaffected when the state chance logic of the subject changes.
10: Give some examples of Behavioral Patterns and how they are used.
Some of the most common Behavioral Patterns are:
a) Iterator -This design pattern is used to access elements of a collection sequentially hiding the internal implementation.
b) Chain of Responsibilities – This design pattern is used where a chain of objects is used to handle the responsibilities. In this design pattern, a request to process the client call is only passed to the next object when the first object fails to process the same.
c) Observer – It is used where a one-to-many relationship exists among the objects and modifying a single object can impact the dependent objects.
d) Mediator -This design pattern encapsulates the communication complexity takes place between different objects and acts as an intermediary between the objects for communication.
To have a successful career as a Java/J2EE developer, one must get a good start. Refer to our book Java/J2EE Design Patterns Interview Questions You’ll Most Likely Be Asked to find out the most likely asked questions and their answers which will help you crack the job that can give you the right start.