HTML oDesk Test Answer 2015



1. 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”);

2. Can we store JavaScript Objects directly into localStorage?

Ans. b) No

3. 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

4. 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);

5. How can an HTML5 canvas size be changed so that it fits the entire window?

<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>


 Ans. b)

6. How can audio files be played in HTML5?

var sound = new Audio(“file.wav”);

Ans. d) sound.play();

7. 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.

8. 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

9. 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.


10. The following are valid use cases of client file/directory access in HTML5, except:

Ans. c) Use of the HTML5 File API

11. 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.

12. What is the internal/wire format of input type=”date” in HTML5?

Ans. b) YYYY-MM-DD

13. What is the limit to the length of HTML attributes?

Ans. c) There is no limit.

14. Q. What is the purpose of the " element in HTML5?"

Ans. c) It is used to define the start of a short quotation.

15. What is the role of the element in HTML5?

Ans. d) It is used to define a definition term.

16. When does the ondragleave mouse event get fired in HTML5?

Ans. b) It gets fired when an element leaves a valid drop target.

17. Which event is fired when an element loses its focus in an HTML5 document?

Ans. c) onblur

18. Which following are valid default values for the HTML5 element?

Ans. b) 2013-05-30

19. Which HTML5 doctype declarations are correct?

Ans. b)
        d)


20. Which is the standard method for clearing a canvas?

Ans. a) context.clearRect ( x , y , w , h );

21. Which media event is triggered when there is an error in fetching media data in HTML5?

Ans. a) onstalled

22. Which media event will be fired when a media resource element suddenly becomes empty?

Ans. d) onemptied

23. Which method of HTMLCanvasElement is used to represent image of Canvas Element?

Ans. a) toDataURL()

24. Which method of the HTMLCanvasElement is used to represent an image of a canvas element?

Ans. a) toDataURL

25. Which of the following attributes are not supported in HTML5?

Ans. b) rev
        c) charset


26. Which of the following are sample use cases for HTML5 web workers?

Ans. d) All of these.

27. Which of the following are the valid values of the element’s target attribute in HTML5?

Ans. a) _blank
        b) _self
        c) _top


28. 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.


29. Which of the following are valid ways to associate custom data with an HTML5 element?

Ans. a)
        c)


30. 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

31. 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; }


32. Which of the following examples contain invalid implementations of the ampersand character in HTML5?

Ans. c) foo &0; bar

33. Which of the following HTML5 features is capable of taking a screenshot of a web page?

Ans. c) Canvas

34. Which of the following is a possible way to get fullscreen video played from the browser using HTML5?

Ans. c)

35. Which of the following is not a valid attribute for the element in HTML5?

Ans. c) disabled

36. Which of the following is not a valid syntax for the element in HTML5?

Ans. b)

36.  Which of the following is the best method to detect HTML5 Canvas support in web browsers?

Ans. d) !!window.HTMLCanvasElemen

37. 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”]);


38. Which of the following is the correct way to check browser support for WebSocket?

Ans. b) console.log(window.WebSocket ? ‘supported’ : ‘not supported’);

39. Which of the following is the correct way to display a PDF file in the browser?

Ans. a)

40. Which of the following is the correct way to store an object in a localStorage?

Ans. a) localStorage.setItem(‘testObject’, JSON.stringify(testObject))



Share on Google Plus

About Unknown

I'm a professional web designer and wordpress theme developer. I also like to write blog post.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment