nerdexam
Oracle

1Z0-900 · Question #50

Identify two valid WebSocket message types for which you can register handlers. (Choose two.)

B (Binary Message) and C (Pong Message) are the two valid WebSocket message types for which you can register handlers, particularly in the Java WebSocket API (JSR 356). In JSR 356, MessageHandler supports three registerable message types: text, binary, and pong. Binary messages…

Create Java Applications using WebSockets

Question

Identify two valid WebSocket message types for which you can register handlers. (Choose two.)

Options

  • AError Message
  • BBinary Message
  • CPong Message
  • DPing Message

Explanation

B (Binary Message) and C (Pong Message) are the two valid WebSocket message types for which you can register handlers, particularly in the Java WebSocket API (JSR 356).

In JSR 356, MessageHandler supports three registerable message types: text, binary, and pong. Binary messages carry raw byte data, and pong messages are received in response to pings your endpoint sends - both are legitimate data payloads worth handling in application logic.

A (Error Message) is wrong because errors are not a WebSocket message type at all; they are handled via a separate @OnError callback or onError method, not a MessageHandler.

D (Ping Message) is wrong because the WebSocket container automatically handles incoming pings and sends the pong response - your application code cannot (and need not) register a handler for them.

Memory tip: Think "BP" - Binary and Pong are the two non-text message types you can handle. Ping is handled for you by the container, and Error is not a message at all.

Topics

#WebSocket handlers#Message types#Handler registration#Java WebSocket API

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice