HTML5 Odesk Test Answers 2015


Q.   Assuming that some text needs to be written on an HTML5 canvas, select a replacement for the commented line below:
<canvas id=”e” width=”200″ height=”200″></canvas>
<script>
var canvas = document.getElementById(“e”);
//insert code here
context.fillStyle = “blue”;
context.font = “bold 16px Arial”;
context.fillText(“Zibri”, 100, 100);
</script>
Ans. c) canvas.getContext(“2d”);


Q. Can we store JavaScript Objects directly into localStorage?
Ans. b) No

            Q.   Consider the following items of a <select> list:
<option value=”89″>Item 1</option>
<option value=”90″>Item 2</option>
Which of the following values would be passed on by clicking the submit button on selecting Item 2 from the list?
Ans. b)  90

Q. Consider the following JavaScript code:
var c=document.getElementById(“myCanvas”);
var ctx=c.getContext(“2d”);
var img=document.getElementById(“img”);
Which method will correctly draw an image in the x=10, y=10 position?
Ans. a) ctx.drawImage(img,10,10);

        Q.   How can an HTML5 canvas size be changed so that it fits the entire window?
        Ans. b) <script type=”text/javascript”>
                  function resize_canvas(){
                  canvas = document.getElementById(“canvas”);
                  if (canvas.width  < window.innerWidth)
                  {
                  width = window.innerWidth;
                  }
                  if (canvas.height < window.innerHeight)
                 { 
                 height = window.innerHeight;
                 }
                 }
                </script>

           Q.   How can audio files be played in HTML5?
var sound = new Audio(“file.wav”);
Ans. d) sound.play();

           Q.   How does a button created by the <button> tag differ from the one created by            an <input> tag?
Ans. d) A button tag can include images as well.

     Q.   In HTML5, which of the following is not a valid value for the type attribute when              used with the tag shown below? Click Me!          
     Ans. a)  button

           Q.   Once an application is offline, it remains cached until the following happens (select            all               that apply):
Ans. a) The application cache is programmatically updated.
   c) The manifest file is modified.
   d) The user clears their browser’s data storage for the site.

    Q. The following are valid use cases of client file/directory access in HTML5, except:
    Ans. c) Use of the HTML5 File API

    Q.  The following link is placed on an HTML webpage:
         http://msdn.com/&#8221; target=”_blank”> MSDN

         What can be inferred from it?
     Ans. b) It will open the site msdn.com in a new window.

     Q.  True or False:
  HTML5 Canvas can be used to create images.
     Ans. a) True


     Q. True or false:
JavaScript objects can be stored directly into localStorage.
      Ans. b) False


     Q. What does P2P streaming mean when web applications establish a P2P HTTP          connection using HTML?
    Ans. a) It means that streaming of a voice/video frame is direct, without using any server between them.


Q.  What is the difference between Server-Sent Events (SSEs) and WebSockets in HTML5?
Ans. a) WebSockets can perform bi-directional (client-server and vice versa) data transfers, while SSEs can only push data to the client/browser.


Q. What is the internal/wire format of input type=”date” in HTML5?
Ans. b) YYYY-MM-DD


Q.  What is the limit to the length of HTML attributes?
Ans. c) There is no limit.


Q. What is the purpose of the element in HTML5?
Ans. c) It is used to define the start of a short quotation.


Q.  What is the role of the element in HTML5?
Ans. d) It is used to define a definition term.


Q. When does the ondragleave mouse event get fired in HTML5?
Ans. b) It gets fired when an element leaves a valid drop target.

Q. Which event is fired when an element loses its focus in an HTML5 document?
Ans. c) onblur

Q. Which following are valid default values for the HTML5 element?
Ans. b) 2013-05-30

Q. Which HTML5 doctype declarations are correct?
Ans. b)
        d)


Q.  
Which is the standard method for
clearing a canvas?
Ans. a) context.clearRect ( x , y , w , h );


Q. Which media event is triggered when there is an error in fetching media data in HTML5?
Ans. a) onstalled

Q. Which media event will be fired when a media resource element suddenly becomes empty?
Ans. d) onemptied


Q. Which method of HTMLCanvasElement is used to represent image of Canvas Element?
Ans. a) toDataURL()


Q. Which method of the HTMLCanvasElement is used to represent an image of a canvas element?
Ans. a) toDataURL

  Q. Which of the following attributes are not supported in HTML5?
  Ans. b) rev
           c) charset


Q. Which of the following are sample use cases for HTML5 web workers?
Ans. d) All of these.


Q. Which of the following are the valid values of the element’s target attribute in HTML5?
Ans. a) _blank
         b) _self
         c) _top


Q. Which of the following are true about the ARIA role attribute in HTML5?
Ans. a) Every HTML element can have an ARIA role attribute specified.
         c) The attribute must have a value that is a set of space-separated tokens
             representing the    various WAI-ARIA roles that the element belongs to.


Q. Which of the following are valid ways to associate custom data with an
     HTML5 element?
Ans. a)
         c)

Q. Which of the following attributes gets hidden when the user clicks on the  
     element that it modifies? (Eg. hint text inside the fields of web forms)
Ans. c) placeholder

Q. Which of the following code is used to prevent Webkit spin buttons from
     appearing on web pages?
Ans. b) input[type=number]::-webkit-inner-spin-button,
             input[type=number]::-webkit-outer-spin-button {
            -webkit-appearance: none;
             margin: 0; }


Q.  Which of the following examples contain invalid implementations of the  
      ampersand character in HTML5?
Ans. c) foo &0; bar

Q.  Which of the following HTML5 features is capable of taking a screenshot

      of a web page?
Ans. c) Canvas


Q. Which of the following is a possible way to get fullscreen video played from
     the browser using HTML5?
Ans. c)

Q. Which of the following is not a valid attribute for the
     HTML5?
Ans. c) disabled

Q.  Which of the following is not a valid syntax for the element in
      HTML5?
Ans. b)


Q. Which of the following is the best method to detect HTML5 Canvas support in web browsers?
Ans. d) !!window.HTMLCanvasElemen

Q. Which of the following is the best method to store an array in localStorage?
Ans. b) var names = []; names[0] = prompt(“New member name?”);
             localStorage[“names”] = JSON.stringify(names);
   var storedNames = JSON.parse(localStorage[“names”]);


Q. Which of the following is the correct way to check browser support for
     WebSocket?
Ans. b) console.log(window.WebSocket ? ‘supported’ : ‘not supported’);

Q. Which of the following is the correct way to display a PDF file in the browser?
Ans. a)
             height=”100%”/>

Q.  Which of the following is the correct way to play an audio file in HTML5?
Ans. a) var snd = new Audio(“file.wav”); snd.play();
         b)
             
             
            


Q. Which of the following is the correct way to store an object in a  
     localStorage?
Ans. a) localStorage.setItem(‘testObject’, JSON.stringify(testObject))


Q.  Which of the following is the correct way to store an object in
      localStorage?
      var obj = { ‘one': 1, ‘two': 2, ‘three': 3 };
Ans. b) localStorage.setItem(‘obj’, JSON.stringify(obj));


Q. Which of the following methods can be used to estimate page load times?
Ans. a) Using _gaq.push([‘_trackPageLoadTime’]) with Google Analytics.
         b) Using the Navigation Timing JavaScript API.


Q. Which of the following shows correct use of client-side data validation in  
     HTML5, on username and password fields in particular?
Ans. a)
             


Q. Which of the following statements are correct with regard to the

and
    
elements of HTML5?
Ans. b) The

element is used to insert the horizontal line within the  
             document and the
element is used to insert a single line break.


Q. Which of the following statements regarding WebSockets is true?
Ans. d) All of the above.

Q. Which of the following video file formats are currently supported by the
     
Ans. b) MPEG 4
         c) ogg


Q. Which of the following video tag attributes are invalid in HTML5?
Ans. d) pause

Q. Which of the following will detect when an HTML5 video has finished
     playing?
Ans. a) var video = document.getElementsByTagName(‘video’)[0];
             onended = function(e) { }

Q. Which of the following will restrict an input element to accept only
     numerical values in a text field?
Ans. a)
        b)
        c)

Q.  You are writing the code for an HTML form and you want the browser to  
     retain the form’s input values. That is, if a user submits the form and     
     presses the browser’s back button, the fully populated form is displayed   
     instead of a blank form. Which of the following HTML 5 attributes will you
     use?
Ans. b) autofocus
        c) autocomplete


Q.  You want to create a link for your website allowing users to email the
       webmaster. How will you implement this if the webmaster’s email address    
       is webmaster@xcompany.com?

Ans. a) webmaster


2 comments

Thank For Posting these Html5 Odesk Test Answers. I got 4.20 marks out of 5 and in top 20%.

Reply

This is really a great thing. Thanks for sharing it in here.
minneapolis web design agency

Reply

Post a Comment