Upwork HTML 5 Test Answer-2015

1. Which of the following are the valid values of the <a> element’s target attribute in HTML5?

Answers:
a. _blank
b. _self
c. _top
d. _bottom

 

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

Answers:
a. <object> <param name=”allowFullScreen” value=”true” />
b. <video allowFullScreen=”true”>
c. <video height=”100%” width=”100%”>
d. None of these.

 

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

Answers:
a. Drag and drop files from the desktop
b. Full file system access
c.Use of the HTML5 File API
d. Use of files as HTML5 input types

 

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

Answers:
a.  toDataURL()
b.  saveAsImage()
c.   saveFile()
d.  exportImage()

 

5. Can we store JavaScript Objects directly into localStorage?
Answers:
a. Yes
b. No

 

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

Answers:
a. onstalled
b. onwaiting
c. onsuspend
d. oninvalid

 

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

Answers:
a. toDataURL
b. toImageURL
c. saveAsPNG
d. saveAsJPEG

 

8. What is the internal/wire format of input type=”date” in HTML5?
Answers:
a. DD-MM-YYYY
b. YYYY-MM-DD
c. MM-DD-YYYY
d. YYYY-DD-MM

 

9. Which of the following is not a valid attribute for the <video> element in HTML5?

Answers:
a. controls
b. autoplay
c. disabled
d. preload

 

10. Which of the following video file formats are currently supported by the <video> element of HTML5?

Answers:
a. CCTV
b. MPEG 4
c. Ogg
d. 3GPP

 

11. Which HTML5 doctype declarations are correct?

Answers:
a. <!doctype html>
b. <!DOCTYPE html>
c. <!DOCTYPE HTML5>
d. <!DOCTYPE HTML>

 

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

Answers:
a. onerror
b. onended
c. onloadeddata
d. onemptied

 

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

Answers:
a. Server-Sent Events
b. SVG
c. Canvas
d. Web Workers

 

14. Which of the following video tag attributes are invalid in HTML5?

Answers:
a. play
b. loop
c. mute
d.pause

 

15. True or False:
HTML5 Canvas can be used to create images.

Answers:
a. True
b. False

 

16. Which following are valid default values for the <input type=”date”> HTML5 element?

Answers:
a. now
b.2013-05-30
c. 2013-30-05
d. today

 

17. True or false:
JavaScript objects can be stored directly into localStorage.

Answers:
a. True
b. False


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

Answers:
a. 65536
b. 64
c. There is no limit.
d. None of these.

 

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

Answers:
a. foo & bar
b. foo &0 bar
c. foo &0; bar
d. foo&&& bar

 

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

Answers:
a. context.clearRect ( x , y , w , h );
b. canvas.width = canvas.width;
c. context.clear();
d. All of these.

 

21. Which of the following <link> attributes are not supported in HTML5?

Answers:
a. sizes
b.rev
c. rel
d. charset

 

22. In HTML5, which of the following is not a valid value for the type attribute when used with the <command> tag shown below?
<command type=”?”>Click Me!</command>

Answers:
a. button
b. command
c. checkbox
d. radio

 

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

Answers:
a. autocomplete
b. autofocus
c. placeholder
d. formnovalidate

 

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

Answers:
a. onfocus
b. onload
c. onblur
d. onselect

 

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

Answers:
a. sound.begin();
b. sound.resume();
c. sound.start();
d. sound.play();

 

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

Answers:
a. accept
b. autofocus
c. autocomplete
d. formtarget

 

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

Answers:
a. Polling URLs in background
b. Syntax highlighting without blocking code editing capabilities in online IDEs
c. Motion tracking input in realtime with a video element
d. All of these.

 

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

Answers:
a. 89
b. 90
c. Item 1
d. Item 2

 

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

Answers:
a.<tr class=”foo” data-id-type=”4″>
b. <tr class=”foo” id-type=”4″>
c. <tr class=”foo” data-id_type=”4″>
d.  All of the above.

 

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

Answers:
a. It gets fired when an element has been dragged to a valid drop target.
b. It gets fired when an element leaves a valid drop target.
c. It gets fired at the end of a drag operation.
d. It gets fired while an element is being dragged.

 

31. What is the role of the <dfn> element in HTML5?

Answers:
a. It is used to define important text.
b. It is used to define computer code text.
c. It is used to define sample computer code.
d. It is used to define a definition term.

 

32. Which of the following statements regarding WebSockets is true?

Answers:
a. It communicates with the server with only the data required by the application.
b. It lowers the latency of connections for interactive web applications.
c. It scales better and consumes less server resources than HTTP AJAX/long-poll.
d. All of the above.

 

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

Answers:
a. var context = canvas.getContext();
b. var context = canvas.getElementById(“context”);
c. var context = canvas.getContext(“2d”);
d. var context = canvas.getElementById(“2d”);

 

34. How does a button created by the <button> tag differ from the one created by an <input> tag?

Answers:
a. An input tag button can be a reset button too.
b. A button tag button can be a reset button too.
c. An input tag button can include images as well.
d. A button tag can include images as well.

 

35. Once an application is offline, it remains cached until the following happens (select all that apply):

Answers:
a. The application cache is programmatically updated.
b. The application cache gets automatically cleared by the browser.
c. The manifest file is modified.
d. The user clears their browser’s data storage for the site.

 

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

Answers:
a. <link rel=”icon” href=”abc.jpg” sizes=”16×16″>
b.<link rev=”stylesheet” href=”abc.css” type=”text/css” target=”_parent”>
c. <link rel=”alternate” type=”application/pdf” hreflang=”fr” href=”manual-fr”>

 

37. What does P2P streaming mean when web applications establish a P2P HTTP connection using HTML?

Answers:
a. It means that streaming of a voice/video frame is direct, without using any server between them.
b. It means that streaming of a voice/video frame is first between one peer to the server then the server to another peer.
c. Communication does not rely on a shared relay server in the network.

 

38. Which of the following will detect when an HTML5 video has finished playing?

Answers:
a. var video = document.getElementsByTagName(‘video’)[0]; video.onended = function(e) { }
b. var video = document.getElementsByTagName(‘video’)[0]; video.onPlayend = function(e) { }
c. var video = document.getElementsByTagName(‘video’)[0]; video.onPlayFinish = function(e) { }
d. var video = document.getElementsByTagName(‘video’)[0]; video.onPlayBackended = function(e) { }

 

39. What is the difference between Server-Sent Events (SSEs) and WebSockets in HTML5?

Answers:
a.WebSockets can perform bi-directional (client-server and vice versa) data transfers, while SSEs can only push data to the client/browser.
b. SSEs can perform bi-directional (client-server and vice versa) data transfers, while WebSockets can only push data to the client/browser.
c. WebSockets and SSEs are functionally equivalent.
d. None of these.

 

39. Which of the following methods can be used to estimate page load times?

Answers:
a. Using _gaq.push([‘_trackPageLoadTime’]) with Google Analytics.
b.Using the Navigation Timing JavaScript API.
c. Page load times cannot be estimated.
d. Using built-in JavaScript methods.

 

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

Answers:
a. #myCanvas {height: 100%; width: 100%;}
b. <script type=”text/javascript”> function resize_canvas(){ canvas = document.getElementById(“canvas”); if (canvas.width < window.innerWidth) { canvas.width = window.innerWidth; } if (canvas.height < window.innerHeight) { canvas.height = window.innerHeight; } } </script>
c. It depends upon the complexity of the canvas, and the frequency of redraws.
d. Calling the JavaScript getWidth() function.

 

41. Which of the following is the correct way to store an object in localStorage?
var obj = { ‘one’: 1, ‘two’: 2, ‘three’: 3 };

Answers:
a. localStorage.setItem(‘obj’, obj);
b. localStorage.setItem(‘obj’, JSON.stringify(obj));
c. localStorage.setItem(‘testObject’, JSON.parse(testObject));
d. localStorage.setItem(obj);

 

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

Answers:
a. var context = canvas.getContext();
b. var context = canvas.getElementById(“context”);
c. var context = canvas.getContext(“2d”);
d. var context = canvas.getElementById(“2d”);

 

43. Which of the following code is used to prevent Webkit spin buttons from appearing on web pages?

Answers:
a. input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
b. input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
c. noindex:-o-prefocus, input[type=number] { padding-right: 1.2em; }
b. input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; padding-right: 1.2em; }

 

44. Which of the following will restrict an input element to accept only numerical values in a text field?

Answers:
a. <input type=”text” pattern=”[0-9]*” />
b. <input type=”number” />
c. <input type=”text” pattern=”\d*”/>
d. <input type=”text” pattern=”number”/>

 

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

Answers:
a. <object type=”application/pdf” data=”filename.pdf” width=”100%” height=”100%”/>
b. <object type=”application/pdf” id=”filename.pdf” width=”100%” height=”100%”/>
c. <input type=”application/pdf” data=”filename.pdf” width=”100%” height=”100%”/>
d. <input type=”application/pdf” src=”filename.pdf” width=”100%” height=”100%”/>

 

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

Answers:
a. isCanvasSupported()
b. !!document.createElement(“canvas”)
c. !isCanvasSupported()
d. !!window.HTMLCanvasElement

 

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

Answers:
a. console.log(WebSocket ? ‘supported’ : ‘not supported’);
b. console.log(window.WebSocket ? ‘supported’ : ‘not supported’);
c. console.log(window[WebSocket] ? ‘supported’ : ‘not supported’);
d. console.log(window[‘WebSocket’] ? ‘supported’ : ‘not supported’);

 

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

Answers:
a. <input name=”username” required /> <input name=”pass” type=”password” required/>
b. <input name=”username” validate=”true”/> <input name=”pass” type=”password” validate=”true”/>
c. <input name=”username” validate/> <input name=”pass” type=”password” validate/>
d. There is no way to implement client-side validation for the username and password fields in HTML5.

 

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

Answers:
a.ctx.drawImage(img,10,10);
b. context.drawImage(img,20,10,10,10);
c. context.drawImage(img,10,20,10,10,20,20,10,10);
d. All of these

 

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

Answers:
a. localStorage.setItem(‘testObject’, JSON.stringify(testObject))
b. localStorage.setItem(‘testObject’, testObject)
c. localStorage.add(‘testObject’, testObject)
d. localStorage.addItem(‘testObject’, testObject)

 

51. Which of the following is the correct way to play an audio file in HTML5?

Answers:
a. var snd = new Audio(“file.wav”); snd.play();
b. <audio controls> <source src=”file.ogg” type=”audio/ogg”> <source src=”file.mp3″ type=”audio/mpeg”> </audio>
c. <source src=”file.mp3″ type=”audio/mpeg”>
d.  All of these.

 

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

Answers:
a/<a  href=”mailto:webmaster@xcompany.com”>webmaster</a>
b. <a href=”webmaster@xcompany.com”>webmaster</a>
c. <a http=”mail:webmaster@xcompany.com”>webmaster</a>
d. <mail http=”send:webmaster@xcompany.com”>webmaster</mail>

 

53. Which of the following are true about the ARIA role attribute in HTML5?

Answers:
a. Every HTML element can have an ARIA role attribute specified.
b. Every HTML element is required 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.
d. There is no ARIA attribute called “role”.

 

54. Which of the following statements are correct with regard to the <hr> and <br> elements of HTML5?

Answers:
a. The <hr> element acts in the same way as the tab key and the <br> element acts in the same way as the shift key.
b.The <hr> element is used to insert the horizontal line within the document and the <br> element is used to insert a single line break.
c. The <hr> element is used to put a line across the page and the <br> element acts in the same way as a return/enter key press.

 

55. The following link is placed on an HTML webpage:
<a href=”http://msdn.com/” target=”_blank”> MSDN </a>
What can be inferred from it?

Answers:
a. It will open the site msdn.com in the same window.
b.It will open the site msdn.com in a new window.
c. It will open the site msdn.com in a frame below.
d. It will not be clickable as it is not formed correctly.

 

56. What is the purpose of the <q> element in HTML5?

Answers:
a. It is used to define the start of a term in a definition list.
b. It is used to define attribute values for one or more columns in a table.
c. It is used to define the start of a short quotation.
d. It is used to define what to show browsers that do not support the ruby element.

 

57. Which of the following is the best method to store an array in localStorage?

Answers:
a. var localStorage[names]=new Array(); localStorage.names[0]=prompt(“New member name?”);
b. var names = []; names[0] = prompt(“New member name?”); localStorage[“names”] = JSON.stringify(names); var storedNames = JSON.parse(localStorage[“names”]);
c. Storage.prototype.setObj = function(key, obj) { return this.setItem(key, JSON.stringify(obj)) } Storage.prototype.getObj = function(key) { return JSON.parse(this.getItem(key)) }
d. localStorage.setItem(‘names_length’, names.length); localStorage.setItem(‘names_0’, names[0]); localStorage.setItem(‘names_1’, names[1]); localStorage.setItem(‘names_’ + n, names[n]);

 

58. Which of the following input element variations will a numeric keypad in mobile browers?

Answer:
a. <input type=”text” pattern=”[0-9]*”/>
b. <input type=”number”/>
c. <input type=”text” pattern=”/d*”/>
d. none of the above.

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.