687). Which of the following is a stateless protocol?
[A]HTML
[B]XHTML
[C]HTTP
[D]XML
Show Answer
Correct Answer: HTTP
Notes:
Answer: c
Explanation: A stateless protocol does not require the server to retain information or status about each user for the duration of multiple requests. HTTP is a stateless protocol, which means that the connection between the browser and the server is lost once the transaction ends.
688). What does the value 2 of the WebSocket attribute Socket.readyState indicate?
[A]Closed connection
[B]Handshake connection
[C]Unestablished connection
[D] Established connection and communication is possible
Show Answer
Correct Answer: Handshake connection
Notes:
Answer: b
Explanation: The WebSocket object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. The readonly attribute readyState represents the state of the connection. It can have the following values:
A value of 0 indicates that the connection has not yet been established.
A value of 1 indicates that the connection is established and communication is possible.
A value of 2 indicates that the connection is going through the closing handshake.
A value of 3 indicates that the connection has been closed or could not be opened.
689). How many WebSocket events are available?
Show Answer
Correct Answer: 4
Notes:
Answer: c
Explanation: Web sockets are defined as a two-way communication between the servers and the clients, which mean both the parties, communicate and exchange data at the same time. There are fourWebSocket events namely:
open
close
message
error
690). Which method is used to close the WebSocket?
[A]Socket.flush()
[B]Socket.close()
[C]Socket.Close()
[D]Socket.dispose()
Show Answer
Correct Answer: Socket.close()
Notes:
Answer: b
Explanation: The Socket.close() is used to close the WebSocket. The Close method closes the remote host connection and releases all managed and unmanaged resources associated with the Socket. WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection.
691). How does the client and the server communicate following the rules defined by the WebSocket protocol?
[A]Long-lived TCP Socket
[B]Short-lived TCP Socket
[C]UDP Socket
[D]HTTP Socket
Show Answer
Correct Answer: Long-lived TCP Socket
Notes:
Answer: a
Explanation: The client and server communicate over a long-lived TCP socket following rules defined by the WebSocket protocol.
692). Which of the following is not a socket property?
[A]onopen
[B]readyState
[C]onmessage
[D]ready
Show Answer
Correct Answer: ready
Notes:
Answer: d
Explanation: There is no Socket property called ready. Various Socket properties include onopen, readystate, ready, binaryTree, onclose, onerror etc.
693). What does the following JavaScript code snippet do?
var httpserver = new http.Server();
[A]Create an HTTP Server
[B]Create HTTP Connection between Client and Server
[C]HTTP Server & Connection
[D]Create a connection between two servers
Show Answer
Correct Answer: Create an HTTP Server
Notes:
Answer: a
Explanation: HTTP defines what actions Web servers and browsers should take in response to various commands. The above code creates an HTTP Server.
694). How can we check the subprotocol being used by the client?
var httpserver = new http.Server();
[A] subprotocol property
[B]protocol property
[C] clientprotocol property
[D] client property
Show Answer
Correct Answer: protocol property
Notes:
Answer: b
Explanation: A WebSocket is a standard bidirectional TCP socket between the client and the server. The socket starts out as an HTTP connection and then “Upgrades” to a TCP socket after an HTTP handshake. Once the connection is established, the client can determine which subprotocol is in use by checking the protocol property of the socket.
695). How will you transmit data using the connection?
var httpserver = new http.Server();
[A]send(data)
[B] Socket.send(“data”)
[C]Socket.send(data)
[D]Socket(data)
Show Answer
Correct Answer: Socket.send(data)
Notes:
Answer: c
Explanation: The Socket.send(data) method transmits data using the connection. This Socket method sends data to connected socket.
696). Which of the following is not a WebSocket event?
var httpserver = new http.Server();
[A]open
[B]close
[C]error
[D]deny
Show Answer
Correct Answer: deny
Notes:
Answer: d
Explanation: There is no WebSocket event named deny. The four WebSocket events are
open
close
message
error
Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.
697). What will be the output of the following JavaScript code?
Show Answer
Correct Answer: 9
Notes:
Answer: b
Explanation: The \v metacharacter is used to find a vertical tab character. \v returns the position where the vertical tab character was found. If no match is found, it returns -1.
698). What will be the output of the following JavaScript code?
[A]true
[B]false
[C]error
[D]null
Show Answer
Correct Answer: true
Notes:
Answer: a
Explanation: The \xxx character is used to find the Latin character specified by an octal number xxx. If no match is found, it returns null.
699). What will be the output of the following JavaScript code?
[A]error
[B]false
[C]true
[D]undefined
Show Answer
Correct Answer: true
Notes:
Answer: c
Explanation: The \xdd character is used to find the Latin character specified by a hexadecimal number dd. The character ‘W’ is represented as x57 in hexadecimal.
700). What will be the output of the following JavaScript code?
[A]true
[B]false
[C]error
[D]undefined
Show Answer
Correct Answer: true
Notes:
Answer: a
Explanation: The \udddd character is used to find the Unicode character specified by a hexadecimal number dddd. If no match is found, it returns null.
701). What will be the output of the following JavaScript code?
[A]false
[B]true
[C]error
[D]undefined
Show Answer
Correct Answer: true
Notes:
Answer: b
Explanation: The \W metacharacter is used to find a non-word character. A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.