Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

Develop skills for building positive relationships.

Answered: 1 week ago

Question

Describe techniques for resolving conflicts.

Answered: 1 week ago

Question

Give feedback effectively and receive it appropriately.

Answered: 1 week ago