程序代写代做代考 case study concurrency Java ER JDBC Refer to the class diagram, screenshots, code listings and API documentation (Figures 1 to 14) in

Refer to the class diagram, screenshots, code listings and API documentation (Figures 1 to 14) in
Appendix A – OABS Case Study.
JAVA STANDARD EDITION
Question 1 [35 marks]
Answer the following question using Java SE solutions.
a) Wai yan, implemented a static method. He writes a main method to test. Read the code in
figure 3. What will be the output, assuming there is no compilation errors? Briefly explain
your answer.
(3 Marks)
b) Your colleague Ruby is crafting group of classes. Codes are shown in figure 4. She could not
compile one of them; she is seeking your guidance.
i. What will you change in figure 4 – in order to compile the classes?
ii. What will be the output, assuming you have fixed the compilation errors correctly? Briefly explain your answer.
(4 Marks)
c) Your team member Samuel has a reuse situation. He needs to convert ArrayList into Array
and LinkedList into Array, also vise versa. Help him by writing two methods
(1) public T[] convertCollectionToArray(List list) (2) public List convertArrayToCollection(T[] array) (4 Marks)
d) Narendra is introducing ‘mileage’ data for each passenger. The mileage is a user defined
class and a member variable in Passenger class. The mileage data has the following characteristics:
– The data grows and shrinks dynamically
– Is Ordered and provides indexed access
Suggest a suitable collection type class for mileage. Will your answer change if the requirement is for an unordered collection? Explain your answers.
(5 Marks)
e) Erin created a class called ListUtility is shown in Figure 5. The purpose of the class is to
provide methods that sorts and searches passengers from a given list. It has the following
methods:
o arrangePassengerById()This method sorts a list provided as argument and returns the sorted list.
o findFirstPassenger() This method returns the first passenger details from a list provided as argument.
o findLastPassenger() This method returns the last passenger from a list provided as argument.

o main() This method is used to test the above methods.
 Inspect the main() method for the usage of the three methods namely arrangePassengerById(),findFirstPassenger()&findLastPassenger()
and provide the code for them.
 Class Passenger implements the Comparable Interface. Identify and add the missing code to this class
(5 Marks)
f) Michael created a stack utility with generic template called MichaelStack.java. The
code is shown in Figure 6. Vicky attempts to test Michael’s class using TestStack.java
(String[] strlist = {‘…’, ‘…’, ‘…’} and Integer[] intlist = {…}).
Vicky
wants to push all data in sequence and pop them out to print and test the “Last In First
Out”
nature of the stack. Help Vicky by completing the main method in TestStack.
(4 Marks)
g) Sun Zheng is coding the data layer in OABS application. Assist her by answering
the
following question (using JDBC and Data Access Object Pattern as appropriate).
PaymentDAO(in figure 7) and OABS ER diagram (figure 2). Carefully look at the PAYMENT
TABLE details (figure 2). Complete the findSalesAmountByDate(…) method. Clearly state
any assumptions made.
(10 Marks)
JAVA ENTERPRISE EDITION – WEB APPLICATION Question 2 [40 marks]
Answer the following question using Java EE Web Components as appropriate. Clearly state any
assumptions you make and take care of exceptions as necessary.
a. Study the code snippets created by Rajna – namely SillyJellyBean.java and MyJBTrial.jsp
(Figures 8 & 9). Assume the context root is “demo”. When executing the JSP file through
browser as below, what is the expected output on the browser screen? Explain your answer
briefly.
http://localhost:8080/demo/MyJBTrial.jsp?a=X&b=Y&c=Z
(3 Marks)
b. Study the code snippet for TestEL.jsp (Figure 10). What is the expected output on the
browser screen? Hint: Just write the results. No explanation needed.
(5 Marks)

c. The view flights page (coded as FlightView.jsp) is a search page based on flight number, city
code and departure date (figure 11). The ‘Search Flights’ button the calls /flightcontroller URI mapped Servlet and set object flist of type ArrayList (Figure 12). It lists all flights that satisfy the search criteria (full
page shown in Figure 13). Write key codes for FlightView.jsp .
(15 Marks)
d. Complete the end potion of SearchServlet (Figure 14) to accommodate the following:
• Check if the list is empty, in such situation the error page (“Error.jsp”) is displayed.
• If the list size is more than 100 records, display tags will be used. Hence a pagination variable is to be set in the session scope before forwarding control to the “Search.jsp” page.
(5 Marks)
e. Your team member (newbie) created a lousy java server page(jsp) with instance variables and
a great deal of scriptlet code. Unfortunately, after extensive load testing, there are several race
conditions in the JSP. Given the tight schedule, list one way to resolve the concurrency
problem, without rewriting the code?
(3 Marks)
f. In OABS application, which of the models suggested below is best suitable for the following
aspects?
i. Web Framework Architecture Model Choices:
1. Request
2. Component
Mention you choice and explain briefly
ii. Web Framework Communication Model Choices:
1. Pull
2. Push
Mention you choice and explain briefly
iii. List any two useful design patterns that are applicable to the OABS web layers. Explain how your suggested design patterns improve the design or
performance.
(9 Marks)