Sockets(Computer Science > Javascript ) Questions and Answers

Question 1. Which of the following is a stateless protocol?
  1.    HTML
  2.    XHTML
  3.    HTTP
  4.    All of the mentioned
Explanation:-
Answer: Option C. -> HTTP

Question 2. What does the value 2 of the WebSocket attribute Socket.readyState indicate?
  1.    Closed connection
  2.    Handshake connection
  3.    Unestablished connection
  4.    Established connection and communication is possible
Explanation:-
Answer: Option B. -> Handshake connection

Question 3. How many WebSocket events are available?
  1.    2
  2.    3
  3.    4
  4.    5
Explanation:-
Answer: Option C. -> 4

Question 4. Which method is used to close the WebSocket?
  1.    Socket.flush()
  2.    Socket.close()
  3.    Socket.Close()
  4.    Socket.dispose()
Explanation:-
Answer: Option B. -> Socket.close()

Question 5. How does the client and the server communicate following the rules defined by the WebSocket protocol?
  1.    Long-lived TCP Socket
  2.    Short-lived TCP Socket
  3.    UDP Socket
  4.    HTTP Socket
Explanation:-
Answer: Option A. -> Long-lived TCP Socket

Question 6. Which of the following are not a socket property?
  1.    onopen
  2.    readyState
  3.    onmessage
  4.    ready
Explanation:-
Answer: Option D. -> ready

Question 7. How can we check the subprotocol being used by the client?
  1.    subprotocol property
  2.    protocol property
  3.    clientprotocol property
  4.    none of the mentioned
Explanation:-
Answer: Option B. -> protocol property

Question 8. How will you transmit data using the connection?
  1.    send(data)
  2.    Socket.send(“data”)
  3.    Socket.send(data)
  4.    Socket(data)
Explanation:-
Answer: Option C. -> Socket.send(data)

Question 9. Which of the following is not a WebSocket event?
  1.    open
  2.    close
  3.    error
  4.    deny
Explanation:-
Answer: Option D. -> deny

Question 10. What does an History object contain?
  1.    URL
  2.    Parameters
  3.    Attribute values
  4.    Property
Explanation:-
Answer: Option A. -> URL