Java EE 7 Application Developer — Question 5
Which statement is true about the relationship between HTTP and WebSockets?
Answer options
- A. A WebSocket connection is a bi-directional HTTP session with message-handling support.
- B. A WebSocket connection is initialized with an HTTP handshake.
- C. A WebSocket connection can be initialized by either client or server.
- D. A WebSocket connection uses HTTP protocol to exchange data with the browser.
Correct answer: D
Explanation
The correct answer is D because WebSocket connections begin with an HTTP handshake, establishing an initial connection before upgrading to a full-duplex communication channel. Option A is incorrect as it misrepresents the nature of the connection; it is not just a session but an upgrade. Option C is misleading because the client must initiate the handshake, while option B is incomplete as it doesn't mention the upgrade process that follows the handshake.