My Report

JavaScript Socket Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "Hello World!"; 
   var patt1 = /\127/g;
   var result = str.match(patt1);
   if(result) 
  	result=true;
   else
  	result=false;
   document.getElementById("demo").innerHTML = result;
}
</script>

2. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "100%!";
   var patt1 = /\W/g;
   var result = str.match(patt1);
   var result = str.match(patt1);
   if(result) 
  	result=true;
   else
  	result=false;
   document.getElementById("demo").innerHTML = result;
}
</script>

3. Which method is used to close the WebSocket?

4. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "hello to \r world."; 
   var patt1 = /\v/;
   var result = str.search(patt1);
   document.getElementById("demo").innerHTML = result;
}
</script>

5. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "Hello World!"; 
   var patt1 = /\x57/g;
   var result = str.match(patt1);
   if(result) 
  	result=true;
   else
  	result=false;

   document.getElementById("demo").innerHTML = result;
}
</script>

6. What does the following JavaScript code snippet do?

var httpserver = new http.Server();

7. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "Visit W3Schools. Hello World!"; 
   var patt1 = /\u0057/g;
   var result = str.match(patt1);
   var result = str.match(patt1);
   if(result) 
  	result=true;
   else
  	result=false;
   document.getElementById("demo").innerHTML = result;
}
</script>

8. What does the value 2 of the WebSocket attribute Socket.readyState indicate?

9. How does the client and the server communicate following the rules defined by the WebSocket protocol?

10. Which of the following is not a socket property?

11. Which of the following is not a WebSocket event?

12. Which of the following is a stateless protocol?

13. How can we check the subprotocol being used by the client?

14. How will you transmit data using the connection?

15. How many WebSocket events are available?


 

Start practicing “1000 MCQs on JavaScript”, and once you are ready, you can take tests on all topics by attempting our “JavaScript Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.