Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 [10 marks) Consider the following Java codes, state whether they are correct or not. State the reasons for incorrect ones. (a) public class
Question 2 [10 marks) Consider the following Java codes, state whether they are correct or not. State the reasons for incorrect ones. (a) public class BufferClass { private static final int CAPACITY = 5; // buffer size private LinkedList queue = new LinkedList(); // Method fwrite should wait until the input 'value' can be added public synchronized void write(int value) { try { if (queue.size() == CAPACITY) { System.out.println("Buffer full..."); wait(); } queue.offer(value); notifyAll(); } catch (InterruptedException ex) { ex.printStackTrace(); } } (b) // Client side program try { Socket s = new Socket (Socket("127.0.0.1", 8888); DataOutputStream dout = new DataOutputStream(s.getInputStream()); } catch (Exception e) { e.printStackTrace(); The Open University of Hong Kong } (c) DataInputStream din; // Assume DataInputStream object 'din' is initialized properly. din.readBoolean(); // Get a boolean value from sender for further // manipulation. (d) Connection connection; // Assume Connection object connection' is initialized properly. try { String str = "select * from student"; PreparedStatement pstmt = connection.prepareStatement(str); pstmt.executeUpdate(); ShoppingCart.jsp JavaBean 'connection is created for handling database manipulation. JavaBean 'cart' is created for storing product(s) selected by a particular customer. Assume the two classes MyConnection and ShoppingCart are defined. class="webdb.My Connection" class="webdb.Shopping Cart" [10]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started