UPWORK TEST » July 29, 2016

Daily Archives: July 29, 2016

Top 10 popular test answers

CSS Test

Published by:

1. Consider the following code snippet:

<div id=”sectors”>
<div id=”A” class=”A”></div>
<div id=”B” class=”B”></div>
<div id=”C” class=”C”></div>
<div id=”D” class=”D”></div>
<div id=”E” class=”E”></div>
</div>
With these style rules:
<style>
#sectors > div {
float: left;
position: relative;
width: 80px;
height: 80px;
margin: 16px;
background-color:red; color: white;
text-align: center;
}
#sectors > div::after {
content: attr(id) ‘-Block’;
}
#sectors > div.changecolor {
background-color: blue;
}
</style>

Which of the following code snippets when inserted into CSS will change the A and B div’s color from red to blue?

Answers:

  1. In style rule add this code “#sectors > div:not(.C):not(.D):not(.E) {background-color: blue;}”
  2. In style rule add this code “#sectors > div:not(.C, .D, .E) {background-color: blue;}”
  3. Both A and B
  4. None of the above

2. Which of the following will create a triangle effect using pure CSS3 on a white background, without making use of background images?

Answers:

  1. It is not possible to do so.
  2. border-color: #a0c7ff #ffffff #ffffff #ffffff; border-style: solid; border-width: 20px; width: 0px; height: 0px;
  3. background-color: #a0c7ff #ffffff #ffffff #ffffff; border-style: solid; border-width: 20px; width: 0px; height: 0px;
  4. background-color: #a0c7ff #ffffff #ffffff #ffffff; border-style: solid; border-width: 1px; width: 10px; height: 10px;

3. Can a percentage value be given in a ruby-align property?

Answers:

  1. Yes
  2. No

4. Consider the following font definition:

font-weight:normal

What is the other way of getting the same result?

Answers:

  1. font-weight:100
  2. font-weight:900
  3. font-weight:400
  4. font-weight:700

5. Consider the following code:

div[class^=”stronger”] { }
{em

}

Which of the following statements is true?

Answers:

  1. It applies the rule only on divs who belong to a class that begins with “stronger”.
  2. It applies the rule only on divs of class “stronger”.
  3. It applies the rule only on divs who belong to a class which end with “stronger”.
  4. It applies the rule only on divs who belong to a class which does not contain “stronger” in its name.

6. For the clear property, which of the following values is not valid?

Answers:

  1. none
  2. left
  3. right
  4. top

7. What will be the output of the following code?
<style>
.foo {
width:100px;
height:50px;
border-width:3px;
-webkit-border-image:
-webkit-gradient(linear, 0 0, 0 100%, from(black), to(red)) 1 100%;
-webkit-border-image:
-webkit-linear-gradient(black, red) 1 100%;
-o-border-image:
-o-linear-gradient(black, red)) 1 100%;
-moz-border-image:
-moz-linear-gradient(black, red) 1 100%;

}
</style>

<div class=”foo”>Lorem</div>

Answers:

  1. The text “Lorem” will be colored black-red.
  2. The div element will be colored black-red.
  3. The border of div element will be colored black-red.
  4. None of these.

8. Which of the following is not a valid value for the font-smooth property?

Answers:

  1. auto
  2. never
  3. always
  4. normal
  5. length

9. Which of the following option does not exist in media groups available in CSS3?

Answers:

  1. continuous or paged
  2. visual or tactile
  3. grid or bitmap
  4. braille or screen

10. Which of the following is not a valid page break?

Answers:

  1. page-break-inside
  2. page-break-outside
  3. page-break-before
  4. page-break-after
  5. None of these

11. Which statement is correct given the following?
box-shadow:30px 20px 10px 5px black;

Answers:

  1. The shadow will be spread out to 30px top, 20px right, 10px bottom, 5px left.
  2. The position of the horizontal black shadow is 30px and the position of the vertical black shadow is 20px and blur distance is 10px and size of shadow is 5px.
  3. The position of the vertical black shadow is 30px and the position of the horizontal black shadow is 20px and size of shadow is 10px and blur distance is 5px.
  4. The shadow will be spread out to 30px top and bottom, 20px left and right with 10px blur distance, 5px shadow size.

12. The min-width property cannot be applied to the following element:

Answers:

  1. button
  2. span
  3. table row

13. Given the following problem:

A drop shadow needs to appear only at the bottom, and no images should be used.
Consider the following code:

-moz-box-shadow: 0px 4px 4px #000;
-webkit-box-shadow: 0px 4px 4px #000;
box-shadow-bottom: 5px #000;

However, this produces shadows on the rest of the element.

Which of the following code snippets will correct the issue?

Answers:

  1. border-bottom:5px solid #ffffff; -webkit-box-shadow: 0px 5px #000000; -moz-box-shadow: 0px 5px #000000; box-shadow: 0px 5px #000000;
  2. -webkit-box-shadow: 0 4px 4px -2px #000000; -moz-box-shadow: 0 4px 4px -2px #000000; box-shadow: 0 4px 4px -2px #000000;
  3. -webkit-box-shadow: 0 4px 4px -2px inside #000000; -moz-box-shadow: 0 4px 4px -2px inside #000000; box-shadow: 0 4px 4px -2px inside #000000;
  4. None of these.

14. Consider the following code:

body { text-replace: “a” “b” “b” “c” }

What will be the output of the following string if the text-replace style is implemented?

andy lives behind cafe

Answers:

  1. ndy lives behind cbfe
  2. cndy lives cehind ccfe
  3. andy lives behind cafe
  4. andy lives cehind bafe

15. What is the default value of the transform-style property?

Answers:

  1. preserve-3d
  2. flat
  3. none
  4. preserve

16. What will be the output of the following code?…
<style>
.foo {
width:100px;
height:50px;
border-width:3px;
-webkit-border-image:
-webkit-gradient(linear, 0 0, 0 100%, from(black), to(red)) 1 100%;
-webkit-border-image:
-webkit-linear-gradient(black, red) 1 100%;
-o-border-image:
-o-linear-gradient(black, red)) 1 100%;
-moz-border-image:
-moz-linear-gradient(black, red) 1 100%;

}
</style>

<div class=”foo”>Lorem</div>

Answers:

  1. The text “Lorem” will be colored black-red.
  2. The div element will be colored black-red.
  3. The border of div element will be colored black-red.
  4. None of these.

17. Which of the following styles is not valid for an image?

Answers:

  1. img { float= left }
  2. img { float: left here }
  3. img { background: “black” }
  4. img { border-width: 10 }
  5. All of the above

18. Suppose that a <tr> tag has 10 <td> tags. In this case which statement is correct given the following?
td:nth-child(3n+0){
background-color: orange;
}

Answers:

  1. It returns a syntax error.
  2. The background color of the fourth td will be orange.
  3. The background color of the third td will be orange.
  4. The background color of every third td will be orange.

19. What is the best method to select all elements except for the last one in an unordered list?

Answers:

  1. Adding a class to each <li> element but last
  2. Using li:not(:last-child) css selector
  3. Using li:last-child selector
  4. None of the above

20. Which of the following will apply a black inner glow with 25% opacity to a page element?

Answers:

  1. box-shadow: 0 0 8px rgba(255,255,255, 0.25);
  2. box-shadow: inset 0 0 8px rgba(0,0,0, 0.25);
  3. box-shadow: 0 0 8px rgba(255,255,255, 25%);
  4. box-shadow: inset 0 0 8px rgba(0,0,0, 25%);

21. Which of the following is the initial value for the column-fill property?

Answers:

  1. auto
  2. balance
  3. none

22. Which of the following can be used to add a shadow around the div element below?
<div>Lorem ipsum</div>

Answers:

  1. box-shadow: 0 0 8px 2px #888;
  2. border-shadow: 0 0 8px 2px #888;
  3. div-shadow: 8px 2px 0 0 #888;
  4. None of these

23. Which of the following will decrease 50px from a DIV element whose width is 100%?

Answers:

  1. width: calc(100% – 50px);
  2. width: reduce(100% – 50px);
  3. width: decrease(100% – 50px);
  4. width: 100% – 50px;

24. Which of the following properties specifies the minimum number of lines of a paragraph that must be left at the bottom of a page?

Answers:

  1. orphans
  2. widows
  3. bottom
  4. overflow
  5. None of these

25. What is the maximum value that can be given to the voice-volume property?

Answers:

  1. 10
  2. 100
  3. 500
  4. None of the above

26. What is the initial value of the font-size property?

Answers:

  1. small
  2. medium
  3. large
  4. default

27. Is there a way to create a pure CSS3 text color gradient?

Answers:

  1. Yes, using the text-gradient property.
  2. Yes, but only for headings.
  3. There is no way to do a text color gradient with CSS3.
  4. None of the above.

28. Consider the following code:

border-opacity:0.7;

Given a div element that needs to have a transparent red border, which of the following code samples will work in conjunction with the code above to accomplish the requirement?

Answers:

  1. border: 1px solid rgba(255, 0, 0, 0.7);
  2. border: 1px solid rgb(255, 0, 0, 0.7);
  3. border: 1px solid rgba(255, 255, 0, 0.7);
  4. border: 1px solid red; opacity: 0.7;

29. What is the initial value of the animation-iteration-count property?

Answers:

  1. 1
  2. 5
  3. None

30. What is the default value of the animation-direction property?

Answers:

  1. none
  2. normal
  3. alternate
  4. inherited

31. Is it possible to combine a background image and CSS3 gradients?

Answers:

  1. It is possible only when two separate styles are used, “background-image” and “gradient”, on an HTML tag.
  2. It is possible only when “background-image” is used.
  3. It is possible only when layered HTML tags are used, “background-image” and “gradient”.
  4. It is not possible to combine a background image and CSS3 gradients.

32. What will happen if the cursor property value is set to none?
Answers:

  1. The default cursor will be displayed.
  2. No cursor will be displayed.
  3. A pointer cursor will be displayed.
  4. A text cursor will be displayed.

33. What will be the outcome of given code?
div[class^=”stronger”] { }
{

}
Answers:

  1. It applies the rule only on divs who belong to a class that begins with “stronger”.
  2. It applies the rule only on divs of class “stronger”.
  3. It applies the rule only on divs who belong to a class which end with “stronger”.
  4. It applies the rule only on divs who belong to a class which does not contain “stronger” in its name.

34. To apply style on every input element except text, which of the following selectors should be used?

Answers:

  1. input:([!type=’text’])
  2. input:not([type=”text”])
  3. input:not([type!=”text”])
  4. input:([type!=’text’])

35. For the clear property, which of the following value is not valid?

Answers:

  1. none
  2. left
  3. right
  4. top

36. Read the following:

@page rotated {size: landscape}
TABLE {page: rotated; page-break-before: right}

What will this code do?

Answers:

  1. It will put all tables on a right-hand side landscape page.
  2. It will rotate the page if the table is positioned at the right side.
  3. It will keep the table in the landscape position and rotate the page.
  4. None of the above

37. What is the initial value of the opacity property?

Answers:

  1. 1
  2. normal
  3. none

38. State whether the following statement is true or false.

If a parent element display property is set to none, its children too will not be rendered.

Answers:

  1. True
  2. False

39. Which of the following filters does SVG support?

Answers:

  1. SVG supports only CSS filters.
  2. SVG supports CSS filters as well as ‘filter’ property of SVG
  3. SVG supports only ‘filter’ property of SVG
  4. SVG does not supports any filters

40. What will happen if the pause property is used as follows?

h2 { pause: 40s 60s }

Answers:

  1. pause-before will be set to 40 seconds and pause-after will be set to 60 seconds.
  2. pause-after will be set to 40 seconds and pause-before will be set to 60 seconds.
  3. pause-after and pause-before will be set to 40 seconds.
  4. pause-after and pause-before will be set to 60 seconds.

41. Which of the following properties allow percentages in their value fields?

Answers:

  1. font-size
  2. font-variant
  3. font-weight
  4. line-height

42. Which of the following is not a valid value for the font-stretch property?

Answers:

  1. condense
  2. normal
  3. semi-narrower
  4. expanded
  5. semi-expanded

43. Which of the following styles is valid?

Answers:

  1. order: “none”;
  2. order= “none”;
  3. order: none;
  4. order= none;
  5. None of these.

44. Which one of the following is appropriate to mirror/flip text by using CSS3?

Answers:

  1. .mirror_text{ -moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1); filter: FlipH; -ms-filter: “FlipH”; }
  2. .mirror_text{ Box-reflect; 20px right; }
  3. .mirror_text{ Box-reflect; 20px left; }
  4. .mirror_text{ -moz-transform: rotate(-180deg); -webkit-transform: rotate(-180deg); transform: rotate(-180deg); }

45. What is the initial value of the marquee-speed property?

Answers:

  1. slow
  2. normal
  3. fast
  4. none

46. Which of the following will apply a gradient transition to #DemoGradient using CSS3?

Answers:

  1. @-webkit-keyframes pulse #DemoGradient { 0% { background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(196,222,242)), color-stop(0.5, rgb(242,242,242)), color-stop(1, rgb(240,240,240))); } 50% { background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(222,252,255)), color-stop(0.5, rgb(242,242,242)), color-stop(1, rgb(240,240,240))); } 100% { background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(196,222,242)), color-stop(0.5, rgb(242,242,242)), color-stop(1, rgb(240,240,240))); } }
  2. #DemoGradient{ background: -webkit-linear-gradient(#C7D3DC,#5B798E); background: -moz-linear-gradient(#C7D3DC,#5B798E); background: -o-linear-gradient(#C7D3DC,#5B798E); background: linear-gradient(#C7D3DC,#5B798E); -webkit-transition: background 1s ease-out; -moz-transition: background 1s ease-out; -o-transition: background 1s ease-out; transition: background 1s ease-out; background-size:1px 200px; border-radius: 10px; border: 1px solid #839DB0; cursor:pointer; width: 150px; height: 100px; } #DemoGradient:Hover{ background-position:100px; }
  3. It is not possible to apply a gradient transition using only CSS3.

47. Using height on transitions is not possible with:

Answers:

  1. height:auto
  2. height:100%
  3. height:0
  4. max-height:100%

48. Consider the following problem:
When trying to apply a CSS3 style to a label of a checked radio button like this:
….
<style>
label:checked { font-weight: bold; }
</style>
….
<input type=”radio” id=”rad” name=”radio”/>
<label for=”rad”>A Label</label>

This does not produce the desired effect.
Which of the following snippets will correct issue?

Answers:

  1. It is not possible to style.
  2. <input id=”rad” type=”radio” name=”rad”><label “rad”>A Label</label>
  3. input[type=”radio”]:checked+label{ font-weight: bold; }
  4. input[type=”radio”]:checked@label{ font-weight: bold; }

49. There are various types of input fields in a HTML page. Choose the appropriate CSS3 code which will have an effect on all inputs, except checkbox and radio.

Answers:

  1. form input:not([type=”radio”], [type=”checkbox”]) { }
  2. input:not([type=”radio”]):not([type=”checkbox”]) { }
  3. input:not([type=”radio & checkbox”]) { }
  4. input:!([type=”radio”]) , input:!([type=”checkbox”]) { }

50. Is it possible to use transition animations with a gradient background?

Answers:

  1. Yes
  2. No

51. What is the difference between float:left; vs display:inline-block; ?

Answers:

  1. There is no difference, both of them have the same results.
  2. display:inline-block; adds whitespace between the elements.
  3. float:left; collapses the parent element on itself.
  4. None of these.

52. What is the range of values (in decimal notation) that can be specified in the RGB color model?

Answers:

  1. 0 to 256
  2. 0 to 255
  3. -250 to 250
  4. -255 to 255

53. Which of the following are not valid values for the target-new property?

Answers:

  1. window
  2. tab
  3. none
  4. parent
  5. current

54. What will be the output of the following rule?

em { color: rgba(0,0,255,1) }

Answers:

  1. Opacity 1 with solid red color
  2. Opacity 0 with solid blue color
  3. Opacity 0 with solid red color
  4. Opacity 1 with solid blue color
  5. None of these

55. While rendering the following code, what is the role of “src” propery?

@font-face {
font-family: “calibriforh1”;
src: local(“calibri”), url(calibri.woff);
}
h1 { font-family: “calibriforh1”, arial, sans-serif; }

Answers:

  1. It’s for searching the user’s system for a “calibri” font, and if it does not exist, it will load the font from the server instead.
  2. It’s for searching the user’s system for a “calibri” font, and if it does not exist, it will load user’s system’s default font instead.
  3. It’s for loading the user’s system’s default font.
  4. None of these.

56. Which of the following statements is true with regard to CSS3 transitions?

Answers:

  1. Using CSS transitions will slow down page upload and produce lag.
  2. The completion of a CSS transition generates a corresponding DOM event. An event is fired for each property that
  3. undergoes a transition. This allows a content developer to perform actions that synchronize with the completion of a transition.
  4. CSS transitions allow DOM events in CSS values to occur smoothly over a specified duration.
  5. None of these.

57. Given that one div element needs to be hidden and on active state needs to be displayed, what will be the output of the following code?

div {
display: none;
-webkit-transition: opacity 1s ease-out;
opacity: 0;
}

div.active {
opacity: 1;
display: block;
}

Answers:

  1. On active state the element is displayed.
  2. On active state the element’s opacity is changed to 1.
  3. On active state the element’s opacity is changed to 0.
  4. Nothing will be shown.

58. Which of the given options is/are equivalent to the following rule?

DIV { line-height: 1.2; font-size: 10pt }

Answers:

  1. DIV { line-height: 1.2em; font-size: 10pt }
  2. DIV { line-height: 12em; font-size: 10pt }
  3. DIV { line-height: 120%; font-size: 10pt }
  4. DIV { line-height: 20%; font-size: 10pt }
  5. DIV { line-height: 80%; font-size: 10pt }

59. What will happen if the following style declaration is applied to an element?

p { margin: 3em 2em }

Answers:

  1. The top and the bottom margins will be 3em and the left and the right margins will be 2em.
  2. The top and the bottom margins will be 2em and the left and the right margins will be 3em.
  3. The top and the left margins will be 3em and the bottom and the right margins will be 2em.
  4. The top and the right margins will be 2em and the bottom and the left margins will be 3em.

60.Problem to solve:
Need to use attribute selector in css to change link on different color and image.
The following code is not working correctly:

<style>
a {
display: block;
height: 25px;
padding-left: 25px;
color:#333;
font: bold 15px Tahoma;
text-decoration: none;
}
a[href=’.pdf’] { background: red; }
</style>
…..
<a href=»/manual.pdf»>A PDF File</a>
Which of the following code snippets will correct issue?

Answers:

  1. a[href$=’.pdf’] { /*css*/ }
  2. a[href#=’.pdf’] { /*css*/ }
  3. a[href@=’.pdf’] { /*css*/ }
  4. a{href$=’.pdf’} [/*css*/ ]

61.Suppose there are 16 elements and a style needs to applied only on every 4th element. Which of the following is correct?

Answers:

  1. div:nth-child(4), div:nth-child(8), div:nth-child(12), div:nth-child(16) { }
  2. div:nth-child(4n) { }
  3. div:nth-child(4n+4) { }
  4. div:nth-child(3n+4)

62.To make childdiv vertically center of given code, what should the “display” property of parentdiv and childdiv be?
#parentdiv
{
width: 200px;
height: 400px;
vertical-align: middle;
}

#childdiv
{
width: 100px;
height: 50px;
}

Vertical Center

Answers:

  1. display:table-cell; for parentdiv and display:inline-block; for childdiv
  2. display:block; for parentdiv and display:inline-block; for childdiv
  3. display:inline-block; for parentdiv and display:table-cell; for childdiv
  4. display:inline-block; for parentdiv and display:inline-block; for childdiv

63.Which of the following can be used to add a shadow around the div element below?

Lorem ipsum

Answers:

  1. . box-shadow: 0 0 8px 2px #888;
  2. border-shadow: 0 0 8px 2px #888;
  3. div-shadow: 8px 2px 0 0 #888;
  4. None of these

64.Is it possible to format numbers with CSS?

Answers:

  1. .No, CSS cannot be used for that purpose.
  2. Yes, it can be done using the number-format property.
  3. Yes, it can be done using the decimal property.
  4. None of these

65.What is true about the background-clip property?
<style>
.foo {
width:100px;
height:50px;
border-width:3px;
-webkit-border-image:
-webkit-gradient(linear, 0 0, 0 100%, from(black), to(red)) 1 100%;
-webkit-border-image:
-webkit-linear-gradient(black, red) 1 100%;
-o-border-image:
-o-linear-gradient(black, red)) 1 100%;
-moz-border-image:
-moz-linear-gradient(black, red) 1 100%;
}
</style>
<div class=»foo»>Lorem</div>
Answers:

  1. The text «Lorem» will be colored black-red.
  2. The div element will be colored black-red.
  3. The border of div element will be colored black-red.
  4. None of these

66.What is true about the background-clip property?

Answers:

  1. The background-clip property specifies the painting area of the background.
  2. The background-clip property is not supported in Internet Explorer 8 and earlier versions.
  3. The background-clip property is supported in Internet Explorer 9+, Firefox, Opera, Chrome, and Safari.
  4. All are correct.

23,169 total views, 59 views today

Top 10 popular test answers

Javascript Test 2016

Published by:

1. Which of the following Array methods in JavaScript runs a function on every item in the Array and collects the result from previous calls, but in reverse?

Answers:

  1. reduce()
  2. reduceRight()
  3. everse()
  4. pop()

2. Which of the following is true about setTimeOut()?

Answers:

  1. The statement(s) it executes run(s) only once.
  2. It pauses the script in which it is called.
  3. clearTimeOut() won’t stop its execution.
  4. The delay is measured in hundredths of a second.
  5. It is required in every JavaScript function.

3. How can the operating system of the client machine be detected?

Answers:

  1. It is not possible using JavaScript.
  2. Using the navigator object
  3. Using the window object
  4. Using the document object
  5. None of these.

4. Which of the following prints “AbBc”?

Answers:

  1. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  2. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’c'[‘toUpperCase’](); alert(result);
  3. var b = ‘a’; var result = b.toUpperCase() + b + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  4. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +C; alert(result);

5. Which of the following descriptions is true for the code below?

var object0 = {};
Object.defineProperty(object0, “prop0”, { value : 1, enumerable:false, configurable : true });
Object.defineProperty(object0, “prop1”, { value : 2, enumerable:true, configurable : false });
Object.defineProperty(object0, “prop2”, { value : 3 });
object0.prop3 = 4;

Answers:

  1. Object ‘object0’ contains 4 properties. Property ‘prop2’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop1’ are available to delete.
  2. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop2’ are available in the for…in loop. Property ‘prop2’ and property ‘prop3’ are available to delete.
  3. Object ‘object0’ contains 4 properties. Property ‘prop0’ and property ‘prop2’ are available in the for…in loop. Property ‘prop0’ and property ‘prop2’ are available to delete.
  4. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop3’ are available to delete.

6. Performance-wise, which is the fastest way of repeating a string in JavaScript?

Answers:

  1. String.prototype.repeat = function( num ) { return new Array( num + 1 ).join( this ); }
  2. function repeat(pattern, count) { if (count < 1) return ”; var result = ”; while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; }
  3. String.prototype.repeat = function(count) { if (count < 1) return ”; var result = ”, pattern = this.valueOf(); while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; };
  4. String.prototype.repeat = function (n, d) { return –n ? this + (d || ”) + this.repeat(n, d) : ” + this };

7. Consider the following variable declarations:

var a=”adam”
var b=”eve”

Which of the following would return the sentence “adam and eve”?

Answers:

  1. a.concatinate(“and”, b)
  2. a.concat(“and”, b)
  3. a.concatinate(” and “, b)
  4. a.concat(” and “, b)

8. Which of the following code snippets will correctly split “str”?

Answers:

  1. <script> var str = ‘something — something_else’; var substrn = str.split(‘ — ‘); </script>
  2. <script> var str = ‘something — something_else’; var substrn = split.str(‘ — ‘); </script>
  3. <script> var str = ‘something — something_else’; var substrn = str.split(‘ – ‘,’ – ‘); </script>
  4. <script> var str = ‘something — something_else’; var substrn = split.str(‘ – ‘,’ – ‘); </script>

9. Which object can be used to ascertain the protocol of the current URL?

Answers:

  1. document
  2. window
  3. history
  4. browser
  5. form
  6. location

10. Which of the following best describes a “for” loop?

Answers:

  1. “for” loop consists of six optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  2. “for” loop consists of five optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  3. “for” loop consists of four optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  4. “for” loop consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.

11. Which of the following descriptions best describes the code below?

<script>
var variable1 = { fastFood: “spaghetti”, length: 10 };
Object.freeze(variable1);
variable1.price = 50;
delete variable1.length;
</script>

Answers:

  1. Object is frozen, a property named “price” is added in the variable1 object, a property named “length” is deleted from this object. At the end of the code, the object “variable1” contains 2 properties.
  2. Object is frozen, a property named “price” is not added in the variable1 object, a property named “length” is deleted from this object. At the end of the code, object “variable1” contains 1 properties.
  3. Object is frozen, a property named “price” is added in the variable1 object, a property named “length” is not deleted from this object. At the end of the code, object “variable1” contains 1 properties.
  4. Object is frozen, a property named “price” is not added in the variable1 object, a property named “length” is not deleted from this object. At the end of the code, object “variable1” contains 2 properties.

12. Which of the following is not a valid HTML event?

Answers:

  1. ondblclick
  2. onmousemove
  3. onclick
  4. onblink

13. Analyze the following code snippet which uses a Javascript Regular Expression character set. What will be the output of this code?

<html>
<body>

<script type=”text/javascript”>
var str = “Is this enough?”;
var patt1 = new RegExp(“[^A-J]”);
var result = str.match(patt1);
document.write(result);
</script>

</body>
</html

Answers:

  1. I
  2. Is
  3. s
  4. I,s,

14. Consider the following image definition:
<img id=”logo” src=”companylogo1.gif” height=”12″ width=”12″ >
Which of the following will change the image to companylogo2.gif when the page loads?

Answers:

  1. logo.source=”companylogo2.gif”
  2. logo.source=”companylogo1.gif”
  3. document.getElementById(‘logo’).src=”companylogo1.gif”
  4. document.getElementById(‘logo’).src=”companylogo2.gif”

15. What is the final value of the variable bar in the following code?

var foo = 9;
bar = 5;
(function() {
var foo = 2;
bar= 1;
}())
bar = bar + foo;

Answers:

  1. 10
  2. 14
  3. 3
  4. 7

16. Which of the following are JavaScript unit testing tools?

Answers:

  1. Buster.js, jQuery, YUI Yeti
  2. QUnit, Modernizr, JsTestDriver
  3. Node.js, Modernizr, Jasmine
  4. Buster.js, YUI Yeti, Jasmine

17. Which of the following can be used for disabling the right click event in Internet Explorer?

Answers:

  1. event.button == 2
  2. event.button == 4
  3. event.click == 2
  4. event.click == 4

18. An image tag is defined as follows:
<img id=”ERImage” width=”100″ height=”100″ onmouseover=”ImageChange()” src=”Image1.jpg”>
The purpose of the ImageChange() function is to change the image source to Image2.jpg. Which of the following should the ImageChange() function look like?

Answers:

  1. document.getElementById(‘ERImage’).src=”Image1.jpg”
  2. document.getElementById(‘ERImage’).src=”Image2.jpg”
  3. document.getElementById(‘ERImage’).style.src=”Image1.jpg”
  4. document.getElementById(‘ERImage’).style.src=”Image2.jpg”

19. Consider the following JavaScript alert:
<script type=”text/JavaScript”>
function message() {
alert(“Welcome to ExpertRating!!!”)
}
</script>
Which of the following will run the function when a user opens the page?

Answers:

  1. body onload=”message()”
  2. body onunload=”message()”
  3. body onsubmit=”message()”
  4. body onreset=”message()”

20. Which of the following code snippets will correctly get the length of an object?

Answers:

  1. <script> var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(index)) size++; } return size; }; var size = Object.size(newObj); </script>
  2. <script> var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(value)) size++; } return size; }; var size = Object.size(newObj); </script>
  3. <script> var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(length)) size++; } return size; }; var size = Object.size(newObj); </script>
  4. <script> var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; var size = Object.size(newObj); </script>

21. In an HTML page, the form tag is defined as follows:
<form onsubmit=”return Validate()” action=”http://www.mysite.com/”>
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What should the validate() function look like?

Answers:

  1. <script type=”text/javascript”> function Validate() { if(document.forms[0].name.value == “”) return true; else return false; } </script>
  2. <script type=”text/javascript”> function Validate() { if(document.forms[0].name.value == “”) return false; else return true; } </script>
  3. script type=”text/javascript”> function Validate() { if(document.forms[0].name== “”) return false; else return true; } </script>
  4. <script type=”text/javascript”> function Validate() { if(document.forms[0].name == “”) return true; else return false; } </script>

22. Which of the following code snippets changes an image on the page?

Answers:

  1. var img = document.getElementById(“imageId”); img.src = “newImage.gif”;
  2. var img = document.getElementById(“imageId”); img.style.src = “newImage.gif”;
  3. var img = document.getElementById(“imageId”); img.src.value = “newImage.gif”;
  4. var img = document.getElementById(“imageId”); img = “newImage.gif”;

23. Which of the following results is returned by the JavaScript operator “typeof” for the keyword “null”?

Answers:

  1. function
  2. object
  3. string
  4. number

24. What will be the final value of the variable “apt”?

var apt=2;
apt=apt<<2;

Answers:

  1. 2
  2. 4
  3. 6
  4. 8
  5. 16

25. How can a JavaScript object be printed?

Answers:

  1. console.log(obj)
  2. console.print(obj)
  3. console.echo(obj);
  4. None of these

26. Which of the following is the correct syntax for using the JavaScript exec() object method?

Answers:

  1. RegExpObject.exec()
  2. RegExpObject.exec(string)
  3. RegExpObject.exec(parameter1,parameter2)
  4. None of these

27. Having an array object var arr = new Array(), what is the best way to add a new item to the end of an array?

Answers:

  1. arr.push(“New Item”)
  2. arr[arr.length] = “New Item”
  3. arr.unshift(“New Item”)
  4. arr.append(“New Item”)

28. Consider the following JavaScript validation function:

function ValidateField()
{
if(document.forms[0].txtId.value ==””)
{return false;}

return true;
}
Which of the following options will call the function as soon as the user leaves the field?

Answers:

  1. input name=txtId type=”text” onreset=”return ValidateField()”
  2. input name=txtId type=”text” onfocus=”return ValidateField()”
  3. input name=txtId type=”text” onsubmit=”return ValidateField()”
  4. input name=txtId type=”text” onblur=”return ValidateField()”

29. Which of following uses the “with” statement in JavaScript correctly?

Answers:

  1. with (document.getElementById(“blah”).style) { background = “black”; color = “blue”; border = “1px solid green”; }
  2. with document.getElementById(“blah”).style background = “black”; color = “blue”; border = “1px solid green”; End With
  3. With document.getElementByName(“blah”).style background = “black”; color = “blue”; border = “1px solid green”; End With
  4. with (document.getElementById(“blah”).style) { .background = “black”; .color = “blue”; .border = “1px solid green”; }

30. Consider the following JavaScript validation function:

<script type=”text/JavaScript”>
function ValidateField()
{
if(document.forms[0].txtId.value ==””)
{return false;}

return true;
}
</script>

Which of the following options will call the function as soon as the user leaves the field?

Answers:

  1. input name=txtId type=”text” onreset=”return ValidateField()”
  2. input name=txtId type=”text” onfocus=”return ValidateField()”
  3. input name=txtId type=”text” onsubmit=”return ValidateField()”
  4. input name=txtId type=”text” onblur=”return ValidateField()”

31. Which of the following modifiers must be set if the JavaScript lastIndex object property was used during pattern matching?

Answers:

  1. i
  2. m
  3. g
  4. s

32. Consider the following image definition:

<img id=”logo” src=”companylogo1.gif” height=”12″ width=”12″ >

Which of the following will change the image to “companylogo2.gif” when the page loads?

Answers:

  1. logo.source=”companylogo2.gif”
  2. logo.source=”companylogo1.gif”
  3. document.getElementById(‘logo’).src=”companylogo1.gif”
  4. document.getElementById(‘logo’).src=”companylogo2.gif”

33. Which of the following will check whether the variable vRast exists or not?

Answers:

  1. if (typeof vRast=”undefined”) {}
  2. if (typeof vRast ==”undefined”) {}
  3. if (vRast.defined =true) {}
  4. if (vRast.defined ==true) {}

34. What would be the use of the following code?

function validate(field) {
var valid=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”;
var ok=”yes”;
var temp;

for(var i=0;i<field.value.length;i++) {
temp=”” + field.value.substring(i,i+1)

if(valid.indexOf(temp)==”-1”) {
ok=”no”;
}
}

if(ok==”no”) {
alert(”error”);
field.focus();
}
}

Answers:

  1. It will force a user to enter only numeric values.
  2. It will force a user to enter only alphanumeric values.
  3. It will force a user to enter only English alphabet character values.
  4. None of these.

35. An image tag is defined as follows:

<img id=”ERImage” width=”100″ height=”100″ onmouseover=”ImageChange()” src=”Image1.jpg”>

The purpose of the ImageChange() function is to change the image source to “Image2.jpg”. Which of the following should the ImageChange() function look like?

Answers:

  1. document.getElementById(‘ERImage’).src=”Image1.jpg”
  2. document.getElementById(‘ERImage’).src=”Image2.jpg”
  3. document.getElementById(‘ERImage’).style.src=”Image1.jpg”
  4. document.getElementById(‘ERImage’).style.src=”Image2.jpg”

36. Which of the following choices will detect if “variableName” declares a function?

<script>
var variableName= function(){};
</script>

Answers:

  1. return variableName;
  2. nameof variableName;
  3. isFunction variableName;
  4. typeof variableName;

37. Which of the following choices will change the source of the image to “image2.gif” when a user clicks on the image?

Answers:

  1. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmousedown=”changeimg(image1.gif)” onmouseup=”changeimg(image2.gif)”
  2. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmouseclick=”changeimg(image2.gif)” onmouseup=”changeimg(image1.gif)”
  3. img id=”imageID” src=”image2.gif” width=”50″ height=”60″ onmousedown=”changeimg(image1.gif)” onmouseup=”changeimg(image2.gif)”
  4. img id=”imageID” src=”image2.gif” width=”50″ height=”60″ onmousedown=”changeimg(image2.gif)” onmouseup=”changeimg(image1.gif)”
  5. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmousedown=”changeimg(‘image2.gif’)” onmouseup=”changeimg(‘image1.gif’)”

38. How can created cookies be deleted using JavaScript?

Answers:

  1. They can’t be deleted. They are valid until they expire.
  2. Overwrite with an expiry date in the past
  3. Use escape() on the value of the path attribute
  4. Use unescape() on the value of the path attribute
  5. The cookie file will have to be removed from the client machine.
  6. Wait till the expiry date is reached

39. What would be the value of ‘ind’ after execution of the following code?

var msg=”Welcome to ExpertRating”
var ind= msg.substr(3, 3)

Answers:

  1. lco
  2. com
  3. ome
  4. Welcome

40. Are the two statements below interchangeable?

object.property
object[”property”]

Answers:

  1. Yes
  2. No

41. Which of the following is not a valid method in generator-iterator objects in JavaScript?

Answers:

  1. send()
  2. throw()
  3. next()
  4. stop()

42. Which of the following code snippets will return all HTTP headers?

Answers:

  1. var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
  2. var req = new XMLHttpAccess(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
  3. var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getResponseHeader().toLowerCase(); alert(headers);
  4. var req = new XMLHttpRequestHeader(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.retrieveAllResponseHeaders().toLowerCase(); alert(headers);

43. Consider the following JavaScript alert:

<script type=”text/JavaScript”>
function message() {
alert(“Welcome to ExpertRating!!!”)
}
</script>

Which of the following will run the function when a user opens the page?

Answers:

  1. body onload=”message()”
  2. body onunload=”message()”
  3. body onsubmit=”message()”
  4. body onreset=”message()”

44. Which of the following is the most secure and efficient way of declaring an array?

Answers:

  1. var a = []
  2. var a = new Array()
  3. var a = new Array(n)
  4. var a

45. Which of the following Regular Expression pattern flags is not valid?

Answers:

  1. gi
  2. p
  3. i
  4. g

46. Which of the following built-in functions is used to access form elements using their IDs?

Answers:

  1. getItem(id)
  2. getFormElement(id)
  3. getElementById(id)
  4. All of these

47. Which of the following statements is correct?

Answers:

  1. There is no undefined property in JavaScript.
  2. Undefined object properties can be checked using the following code: if (typeof something == null) alert(“something is undefined”);
  3. It is not possible to check for undefined object properties in JavaScript.
  4. Undefined object properties can be checked using the following code: if (typeof something === “undefined”) alert(“something is undefined”);

48. Which of the following correctly uses a timer with a function named rearrange()?

Answers:

  1. tmr=setTimeout(“rearrange ()”,1)
  2. tmr=Timer(1,”rearrange ()”)
  3. tmr=Timer(“rearrange ()”,1)
  4. tmr=setTimeout(1,”rearrange ()”)

49. Which of the following can be used to escape the ‘ character?

Answers:

  1. *
  2. \
  3. @
  4. #
  5. %
  6. |
  7. ~

50. Which event can be used to validate the value in a field as soon as the user moves out of the field by pressing the tab key?

Answers:

  1. onblur
  2. onfocus
  3. lostfocus
  4. gotfocus
  5. None of these

51. When setting cookies with JavaScript, what will happen to the cookies.txt data if the file exceeds the maximum size?

Answers:

  1. The script automatically generates a run-time error.
  2. The script automatically generates a load-time error.
  3. All processes using document.cookie are ignored.
  4. The file is truncated to the maximum length.

52. Which of the following are not global methods and properties in E4X?

Answers:

  1. ignoreComments
  2. ignoreWhiteSpace
  3. setName()
  4. setNamespace()
  5. ignoreComments and ignoreWhiteSpace
  6. setName() and setNamespace()

53. Which of the following will change the color of a paragraph’s text to blue when a user hovers over it, and reset it back to black when the user hovers out?

Answers:

  1. <p onmouseover=”style.color=’black'” onmouseout=”style.color=’blue'”> The text of the paragraph..</p>
  2. <p onmouseover=”style.color=’blue'” onmouseout=”style.color=’black'”> The text of the paragraph..</p>
  3. <p onmouseout=”style.color=’blue'”> The text of the paragraph..</p>
  4. <p onmouseover=”style.color=’blue'”> The text of the paragraph..</p>
  5. <p onmousein=”style.color=’blue'” onmouseout=”style.color=’black'”> The text of the paragraph..</p>

54. What is the purpose of while(1) in the following JSON response?

while(1);[[‘u’,[[‘smsSentFlag’,’false’],[‘hideInvitations’,’false’],[‘remindOnRespondedEventsOnly’,’true’],[‘hideInvitations_remindOnRespondedEventsOnly’,’false_true’],[‘Calendar ID stripped for privacy’,’false’],[‘smsVerifiedFlag’,’true’]]]]

Answers:

  1. It’s invalid JSON code.
  2. It makes it difficult for a third-party to insert the JSON response into an HTML document with a <script> tag.
  3. It iterates the JSON response.
  4. It prevents the JSON response from getting executed.

55. Consider the three variables:

someText = ‘JavaScript1.2’;
pattern = /(w+)(d).(d)/i;
outCome = pattern.exec(someText);

What does outCome[0] contain?

Answers:

  1. true
  2. false
  3. JavaScript1.2
  4. null
  5. 0

56. Which of the following choices will turn a string into a JavaScript function call (case with objects) of the following code snippet?

<script>
window.foo = {
bar: {
baz: function() {
alert(‘Hello!’);
}
}
};
</script>

Answers:

  1. bar[‘baz’]();
  2. object[‘foo’][‘bar’][‘baz’]();
  3. document[‘foo’][‘bar’][‘baz’]();
  4. window[‘foo’][‘bar’][‘baz’]();

57. Which of the following determines whether cookies are enabled in a browser or not?

Answers:

  1. (navigator.Cookie)? true : false
  2. (application.cookieEnabled)? true : false
  3. (navigator.cookieEnabled)? true : false
  4. (application.cookie)? true : false

58. Which of the following options can be used for adding direct support for XML to JavaScript?

Answers:

  1. E4X
  2. egex
  3. Generators and Iterators
  4. let

59. Which of the following will detect which DOM element has the focus?

Answers:

  1. document.activeElement
  2. document.ready
  3. document.referrer
  4. document.getelementbyid

60. Which of the following will randomly choose an element from an array named myStuff, given that the number of elements changes dynamically?

Answers:

  1. randomElement = myStuff[Math.floor(Math.random() * myStuff.length)];
  2. randomElement = myStuff[Math.ceil(Math.random() * myStuff.length)];
  3. randomElement = myStuff[Math.random(myStuff.length)];
  4. randomElement = Math.random(myStuff.length);

61. How can global variables be declared in JavaScript?

Answers:

  1. All variables are local in JavaScript.
  2. Declare the variable between the ‘script’ tags, and outside a function to make the variable global
  3. Precede the variable name with the constant global
  4. Declare the variable in an external file

62. Which of the following objects in JavaScript contains the collection called “plugins”?

Answers:

  1. Location
  2. Window
  3. Screen
  4. Navigator

63. What will be output of the following code?

function testGenerator() {
yield “first”;
document.write(“step1”);

yield “second”;
document.write(“step2”);

yield “third”;
document.write(“step3”);
}

var g = testGenerator();
document.write(g.next());
document.write(g.next());

Answers:

  1. firststep1second
  2. step1step2
  3. step1
  4. step1step2step3

64. Which of the following methods will copy data to the Clipboard?

Answers:

  1. execClipboard(‘Copy’)
  2. copyCommand(‘Clipboard’)
  3. execCommand(‘Copy’)
  4. execClipboard(‘Copy’)

65. Which of the following code snippets trims whitespace from the beginning and end of the given string str?

Answers:

  1. str.replace(/^s+|s+$/g, ”);
  2. str.replace(/^s+/,”);
  3. str.replace(/s+$/,”);
  4. str.replace(/s+/g,’ ‘);

66. What is the difference between call() and apply()?

Answers:

  1. The call() function accepts an argument list of a function, while the apply() function accepts a single array of arguments.
  2. The apply() function accepts an argument list of a function, while the call() function accepts a single array of arguments.
  3. The call() function accepts an object list of a function, while the apply() function accepts a single array of an object.
  4. The call() function accepts an object list of a function, while the apply() function accepts a single array of an object.

67. Which of the following code snippets is more efficient, and why?

<script language=”JavaScript”>
for(i=0;i<document.images.length;i++)
document.images[i].src=”blank.gif”;
</script>

<script language=”JavaScript”>
var theimages = document.images;
for(i=0;i<theimages.length;i++)
theimages[i].src=”blank.gif”
</script>

Answers:

  1. Both are equally efficient.
  2. The first code is more efficient as it contains less code.
  3. The first code is more efficient as it employs object caching.
  4. The second code is more efficient as it employs object caching.

68. What is the meaning of obfuscation in JavaScript?

Answers:

  1. Obfuscation is a keyword in JavaScript.
  2. Making code unreadable using advanced algorithms.
  3. Decrypting encrypted source code using advanced algorithms.
  4. None of these.

69. Which of the following JavaScript Regular Expression modifiers finds one or more occurrences of a specific character in a string?

Answers:

  1. ?
  2. *
  3. +
  4. #

70. Which of the following is not a valid JavaScript operator?

Answers:

  1. |
  2. ===
  3. %=
  4. ^

71. Which of the following code snippets returns “[object object]”?

Answers:

  1. <script> var o = new Object(); o.toSource(); </script>
  2. <script> var o = new Object(); o.valueOf(); </script>
  3. <script> var o = new Object(); o.toString(); </script>
  4. <script> var o = new Object(); o.getName(); </script>

72. Which of the following can be used to invoke an iframe from a parent page?

Answers:

  1. window.frames
  2. document.getElementById
  3. document.getelementsbyname
  4. document.getelementsbyclassname

73. Select the following function that shuffles an array?

Answers:

  1. function shuffle(array) { var tmp, current, top = array.length; if(top) while(–top) { current = Math.floor(Math.random() * (top + 1)); tmp = array[current]; array[current] = array[top]; array[top] = tmp; } return array; }
  2. function shuffle(array) { return array.sort(function(a,b) { return (a-b); }); }
  3. function shuffle(array) { var results = new Array(); var sorted_arr = array.sort(); for (var i = 0; i < array.length – 1; i++) { if (sorted_arr[i + 1] == sorted_arr[i]) { results.push(sorted_arr[i]); } } return results; }
  4. function shuffle(array) { for (var tmp, cur, top=array.length; top–;){ cur = (Math.random() * (top + 1)) << 0; tmp = array[cur]; array[cur] = array[top]; array[top] = tmp; } return array.sort(); }

74. Which of the following code snippets removes objects from an associative array?

Answers:

  1. delete array[“propertyName”];
  2. array.propertyName.remove();
  3. array.splice(index, 1);
  4. array[“propertyName”].remove();

75. What is the error in the statement: var charConvert = toCharCode(‘x’);?

Answers:

  1. toCharCode() is a non-existent method.
  2. Nothing. The code will work fine.
  3. toCharCode only accepts numbers.
  4. toCharCode takes no arguments.

76. What value would JavaScript assign to an uninitialized variable?

Answers:

  1. NaN
  2. null
  3. undefined
  4. false

77. What does the following JavaScript code do?

contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}

Answers:

  1. It calculates an array’s length.
  2. It compares ‘a’ and ‘obj’ in an array.
  3. The code will cause an error.
  4. It checks if an array contains ‘obj’.

78. If an image is placed styled with z-index=-1 and a text paragraph is overlapped with it, which one will be displayed on top?

Answers:

  1. The paragraph.
  2. The image.
  3. It depends on other rules.

79. Which of the following code snippets gets an image’s dimensions (height & width) correctly?

Answers:

  1. var img = document.getElementById(‘imageid’); var width = img.clientWidth; var height = img.clientHeight;
  2. var img = document.getElementById(‘imageid’); var width = img.width; var height = img.height;
  3. var img = document.getElementById(‘imageid’); var width = img.getAttribute(‘width’); var height = img.getAttribute(‘height’);
  4. var img=document.getElementById(“imageid”); var width=img.offsetWidth; var height=img.offsetHeight;

80. Which of the following are correct values of variableC, and why?

<script>
variableA = [6,8];
variableB =[7,9];
variableC = variableA + variableB;
</script>

Answers:

  1. 6, 7, 8 and 9. The + operator is defined for arrays, and it concatenates strings, so it converts the arrays to strings.
  2. 6, 15 and 9. The + operator is defined for arrays, and it concatenates numbers, so it converts the arrays to numbers.
  3. 6, 8, 7 and 9. The + operator is defined for arrays, and it concatenates strings, so it converts the arrays to strings.
  4. 6, 87 and 9. The + operator is not defined for arrays, and it concatenates strings, so it converts the arrays to strings.

81. The following are the samples for getting a selected value in the from a dropdown list:

<select id=”ddlViewBy”>
<option value=”1″>test1</option>
<option value=”2″ selected=”selected”>test2</option>
<option value=”3″>test3</option>
</select>

Which code block is correct?

Answers:

  1. var e = document.getElementById(“ddlViewBy”); var strUser = e.options[e.selectedIndex].text;
  2. var e = document.getElementById(“ddlViewBy”); var strUser = e.options[e.selectedIndex].value;
  3. var e = document.getElementByName(“ddlViewBy”); var strUser = e.options[e.selectedIndex].text;
  4. var e = document.getElementByName(“ddlViewBy”); var strUser = e.options[e.selectedIndex].value;

82. var profits=2489.8237

Which of the following code(s) produces the following output?

output : 2489.824

Answers:

  1. profits.toFixed(4)
  2. profits.toFixed(3)
  3. profits.formatDollar(3)
  4. profits.nuberFormat(3)

83. A form contains two fields named id1 and id2. How can you copy the value of the id2 field to id1?

Answers:

  1. document.forms[0].id1.value=document.forms[0].id2.value
  2. document.forms[0].id2.value=document.forms[0].id1.value
  3. document.id1.value=document.id2.value
  4. document.id2.value=document.id1.value

84. Which of the following code snippets will toggle a div element’s background color?

<button id=”toggle”>Toggle</button>
<div id=”terd”>Change Background Color.</div>

Answers:

  1. <script> var button = document.getElementById(‘toggle’); button.click = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; }; </script>
  2. <script> var button = document.getElementById(‘toggle’); button.ready = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; }; </script>
  3. <script> var button = document.getElementById(‘toggle’); button.focus = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; }; </script>
  4. <script> var button = document.getElementById(‘toggle’); button.onclick = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; }; </script>

85. How can the user’s previously navigated page be determined using JavaScript?

Answers:

  1. It is not possible in JavaScript. This can be done only through server-side scripting.
  2. Using the document.referrer property
  3. Using the window object
  4. None of these

86. Which of the following is not a valid method for looping an array?

Answers:

  1. var a= [1,2]; for (var i = 0; i < a.length; i++) { alert(a[i]); }
  2. var a= [1,2]; a.forEach( function(item) { alert(item); })
  3. var a= [1,2]; a.map( function(item) { alert(item); })
  4. var a= [1,2]; a.loop( function(item) { alert(item); })

87. Which of the following correctly sets a class for an element?

Answers:

  1. document.getElementById(elementId).className = “Someclass”;
  2. document.getElementById(elementId).setAttribute(“className”, “Someclass”);
  3. document.getElementById(elementId).class = “Someclass”;
  4. document.getElementById(elementId).style = “Someclass”;

88. An HTML form contains 10 checkboxes all named “chkItems”. Which JavaScript function can be used for checking all the checkboxes together?

Answers:

  1. function CheckAll() { for (z = 0; z < document.forms.chkItems.length; z++) { document.forms.chkItems[z].checked=true } }
  2. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems[z].checked=true } }
  3. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=true } }
  4. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=false } }

89.Which of the following is not a valid Date Object method in JavaScript?

Answers:

  1. parse()
  2. setDay()
  3. setTime()
  4. valueOf()

90.Which event can detect when the user highlights text within a text or textarea object?

Answers:

  1. onSelect()
  2. onBlur
  3. onChange()
  4. onMove
  5. None of these

91.Consider the following code snippet:
var myJSONObject =
{«ircEvent»: «PRIVMSG», «method»: «newURI», «regex»: «^http://.*»};

What is the best way to remove the property ‘regex’, so the result would be this code snippet?

myJSONObject ==
{«ircEvent»: «PRIVMSG», «method»: «newURI»};

Answers:

  1. myJSONObject.regex.delete;
  2. myJSONObject.regex.remove;
  3. delete myJSONObject.regex;
  4. remove myJSONObject.regex;

92.Which of the following is the best way to show both single and double quotes in the same sentence

Answers:

  1. alert(«It’s «+’»game»‘+» time.»);
  2. alert(‘It\’s \»game\» time.’);
  3. alert(‘It\’\s «game» time.’);
  4. alert(‘It\’s «game» time.’);

93.Which of the following statements is true regarding importing JavaScript files inside of other JavaScript files?

Answers:

  1. There is no import/include/require keyword in JavaScript, but there ways to import JS files inside of other JS files.
  2. There is an import keyword in JavaScript, which allows importing JS files inside of other JS files.
  3. There is no option to do so in JavaScript.

94. Which of the following shortcuts can be used for writing multiple document.write statements?

Answers:

  1. for(document){}
  2. with(document) {}
  3. withThis(document){}
  4. None of these

95.In JavaScript, the encodeURI() function is used to encode special characters. Which of the following special characters is/are an exception to that rule?
A. £
B. €
C. @
D. $
Answers:

  1. A
  2. B
  3. C
  4. D
  5. A and B
  6. C and D

96.Consider the following code:

<form>
<textarea id=»foo» name=»foo»></textarea>
</form>

Which of the following is the best method to get the line number of the form’s text area?
Answer:

  1. A<script> foo.value.split(/\r\n\|\r\|\n/g); </script>
  2. <script> foo.value.split(/\r\/n\|\r\|\n/g); </script>
  3. <script> foo.value.split(/\rn\|\r\|\n/g); </script>
  4. <script> foo.value.split(/\r\n|\r|\n/g); </script>

97.Consider the following code:
var setter=new Object()
setter.color=»blue»
How would you delete the color property of the variable seter?

Answer:

  1. setter.color delete;
  2. delete setter.color
  3. delete(setter.color)
  4. setter.color.delete

98. Is the following statement regarding expression closures in JavaScript true or false?
The syntax function(x) {return x*x;} can be written as function(x) x*x.

Answer:

  1. Yes
  2. No

99.Which of the following statements regarding this String prototype is correct?
String.prototype.doSomething = function(suffix) {
return this.indexOf(suffix, this.length — suffix.length) !== -1;
};
Answer:

  1. This method determines whether or not a string ends with another string.
  2. This method determines whether or not a string begins with another string.
  3. This method returns the position of the last occurrence of a specified value in a string.
  4. This method returns the position of the first occurrence of a specified value in a string.

100.What will be the result of the following code?
document.getElementById(“banana”).className = document.getElementById(“banana”).className.replace(/(?:^|\s)apple(?!\S)/g ,’e’ );
Answer:

  1. Replace class ‘apple’ with ‘g’ in the HTML element which contains ID ‘banana’
  2. Replace current class with ‘apple’ in the HTML element which contains ID ‘banana’
  3. Replace class ‘apple’ with ‘e’ in the HTML element which contains ID ‘banana’
  4. Replace ID ‘apple’ with ‘banana’ in the HTML element which contains ID ‘banana’ and class ‘g’

101.Which of the following will determine if the user’s browser is named “Netscape”?

Answer:

  1. if(appName==”Netscape”){}
  2. if(document.appName==”Netscape”){}
  3. if(navigator==”Netscape”){}
  4. if(browser==”Netscape”){}
  5. None of these

102. Given a p element with some text content, which of the following code snippets sets the background color of the text to yellow, its color to red, and its font size to 20px?

Answer:

  1. var p = document.getElementById(elementId);
    p.setAttribute(«style», «background-color:yellow;color:red;font-size:20px;»);
  2. var p = document.getElementById(elementId);
    p.style.background = ‘yellow’;
    p.style.color= ‘red’;
    p.style.size= ’20px’;
  3. var p = document.getElementById(elementId);
    p.style.background = ‘yellow’;
    p.style.color= ‘red’;
    p.style.font.size= ’20px’;
  4. var p = document.getElementById(elementId);
    p.setAttribute(«style», «background-color:red;color:yellow;font-size:20;»);

103.Which of the following are not valid HTML events?

Answer:

  1. onmouseover
  2. onmouseout
  3. onmouseabove
  4. onmousedown
  5. onmousein

104.Which of the following options is used to access the attributes in E4X?

Answer:

  1. @
  2. ::
  3. #
  4. *

105.Which of the following can be used to write a JavaScript function that will accept user input?

Answer:

  1. The prompt method
  2. The alert method
  3. A form field
  4. All of these

106.Which of the following prints «AbBc»?

Answer:

  1. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  2. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  3. var b = ‘a’; var result = b.toUpperCase() + b + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  4. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +C; alert(result);

107.Which of these options is the most maintainable way to attach JavaScript functionality to an HTML element?

Answer:

  1. <p onclick=»alert(‘You clicked me!’)»> some text </p>
  2. <script> function fun(){alert(‘You clicked me!’)} </script>
    <a onclick=fun()>…</a>
  3. <script>
    function fun(){ alert(‘You clicked me!’); };
    var el = document.getElementById(«click-target»);
    el.onClick = fun;
    </script>
    <a id=»click-target»>…</a>
  4. <a href=»javascript:alert(‘You clicked me!’)»>…</a>

108.Which of these options is the most maintainable way to attach JavaScript functionality to an HTML element?
<html>
<body>
<script type=»text/javascript»>
function validate() {
var chk=»ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz»;
var ok=»yes»;
var temp;
var field1=document.getElementById(«t1»);
var field=field1.value.substring(field1.value.length-1,field1.value.length);
if(chk.indexOf(field)==»-1″) {
alert(«error»);
field1.value=(field1.value).slice(0,field1.value.length-1);
}
}
</script>
<input type=»text» id=»t1″ onkeyup=»validate()» onkeypress =»validate()»/>
</body>
</html>
Answer:

  1. The code will cause an error alert to be displayed if a numeric character is entered, and the numeric character is removed.
  2. The code will cause an error alert to be displayed if a non-numeric character is entered, and the non-numeric character is removed.
  3. The code will cause an error alert to be displayed if a numeric character is entered, and the value of textbox is reset.
  4. The code will cause an error alert to be displayed if a non-numeric character is entered, and the value of textbox is reset.

109. What would be the default setting for the expires attribute of the document.cookie property?

Answers:

  1. The duration of the browser session
  2. The duration the current document stays loaded
  3. Twenty-four hours from the time the cookie is set
  4. There is no default setting
  5. The duration for which the machine is on

110.Which of the following choices will remove a selection option from the code below?
<button id”newbtn” onclick=”g();”>Remove</button>
<select name=”selectBox” id=”selectBox”>
<option value=”option1″>option1</option>
<option value=”option2″>option2</option>
<option value=”option3″>option3</option>
<option value=”option4″>option4</option>
</select>
Answers:

  1. <script>
    function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.deleteChild(d_nested);
    }
    </script>
  2. ><script>
    function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.clearChild(d_nested);
    }
    </script>
  3. <script>
    function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.emptyChild(d_nested);
    }
    </script>
  4. <script>
    function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.removeChild(d_nested);
    }
    </script>

111.Which of the following is incorrect regarding Strict mode in JavaScript?

Answer:

  1. It catches some common coding errors, throwing exceptions.
  2. It enables features that are confusing or poorly thought out.
  3. It prevents, or throws errors, when relatively «unsafe» actions are taken (such as gaining access to the global object).

112. Which of the following is incorrect regarding Strict mode in JavaScript?
var a = ‘A’.charCodeAt(0) + 5;
var b = ‘c’.charCodeAt(0) + 1;
var c = 0;
for (var i = 0; i < 10; i++) {
c = c + (a+b % 2);
}
alert(c);

Answer:

  1. 700
  2. 60
  3. 0
  4. 760

113. Which of the following is/are true regarding JavaScript and multi-threading/concurrency?

Answer:

  1. JavaScript is single-threaded, forcing asynchronous events to a queue to wait for execution.
  2. JavaScript is multi-threaded, and behaves in a synchronous manner.
  3. JavaScript can be single or multi-threaded, depending on the browser’s capabilities.
  4. None of these.

114. Which of the following will change the color of the text box to green, as long as the user is pressing a key?

Answer:

  1. input type=»text» onkeydown=»color(‘white’)» onkeyup=»color(‘green’)» name=»txtName»
  2. input type=»text» onkeydown=»color(‘green’)» onkeyup=»color(‘white’)» name=»txtName»
  3. input type=»text» onkeydown=»color(‘green’)» name=»txtName»
  4. input type=»text» onkeydown=»color(‘white’)» name=»txtName»
  5. input type=»text» onkeypress=»color(‘green’)» onkeyup=»color(‘white’)» name=»txtName»

115. In an HTML page, the form tag is defined as follows:
<form onsubmit=»return Validate()»

action=»http://www.mysite.com/»>
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What should the validate() function look like?

Answer:

  1. <script type=»text/javascript»> function Validate() { if(document.forms[0].name.value == «») return true; else return false; } </script>
  2. <script type=»text/javascript»> function Validate() { if(document.forms[0].name.value == «») return false; else return true; } </script>
  3. script type=»text/javascript»> function Validate() { if(document.forms[0].name== «») return false; else return true; } </script>
  4.  <script type=»text/javascript»> function Validate() { if(document.forms[0].name == «») return true; else return false; } </script>

116. Which of the following statements are true regarding the code below?
<script>
alert(«foo» === new String(«foo»)); // output false
</script>

Answer:

  1. The «===» operator always returns false.
  2. The «===» operator returns true only if they refer to the same object (comparing by reference) and if both the primitive and the object have the same value.
  3. The «===» operator returns true only if the object (comparing by reference) and the primitive have the same value.
  4. The «===» operator does not work for objects.

117.Which of the following statements are true regarding the «this» keyword in JavaScript?

Answer:

  1. The value of «this» can be set by assignment during execution, and it will be the same each time the function is called.
  2. Inside a function, the value of «this» depends on how many times the function is called.
  3. Inside a function, the value of «this» depends on how the function is called (as a simple call, an object method, a constructor, etc.).
  4. In strict mode, the value of «this» may change from whatever it is set to, when entering the execution context.

118.Which of the following is not a correct way to empty the array a?

Answer:

  1. a = new Array();
  2. a = [];
  3. a.splice(0,a.length);
  4. a.clear()

119.Which of the following is the correct way to resize an iframe based on content?

Answer:

  1. function resizeIframe(height)
    {document.getElementById(‘frame_name_here’).height = parseInt(height)+60;}
    <iframe id=’frame_name_here’ src=’src.htm’></iframe>
  2. function resizeIframe(height)
    {document.getElementByName(‘frame_name_here’).height = parseInt(height)+60;}
    <iframe id=’frame_name_here’ src=’src.htm’></iframe>
  3. function resizeIframe(height)
    {document.getElementByDivId(‘frame_name_here’).height = parseInt(height)+60;}
    <iframe id=’frame_name_here’ src=’src.htm’></iframe>
  4. None of these

120.Which of the following is not a valid JavaScript function?

Answers:

  1. apply()
  2. call()
  3. toString()
  4. All the other options are valid.

121.What does the following code snippet do?

<input type=»radio»name=»r1″value=»radio1″onclick=»this.checked=false;alert(‘sorry’)»>

Answers:

  1. The code is invalid.
  2. The code makes it necessary for the user to select the radio button.
  3. The code disables the radio button.
  4. The code displays an alert when the user selects the button.

122.How can properties be added to an object class?

Answers:

  1. With the prototype() method
  2. With the prototype property
  3. It cannot be done.
  4. With the «this» object

123.Which of the following will correctly check if an object is an array?
Note: There may be more than one right answer.

Answers:

  1. Object.prototype.toString.call(arr) === ‘[object Array]’
  2. Object.isArray(arr)
  3. None of these
  4. With the «this» object

124.Which of the following check if an object has a specific property?

Answers:

  1. hasOwnProperty()
  2. hasProperty()
  3. It is browser-dependent
  4. None of these

125. Given the following window.open function:
window.open(url,name,»attributes»)
How can it be ensured that different URLs are opened in the same window?

Answers:

  1. The second attribute, name, should be the same.
  2. The name attribute should be null.
  3. The name attribute should be omitted.
  4. The name attribute should be different.
  5. None of these.

126.Which of the following code snippets renders a button invisible?

Answers:

  1. var button = document.getElementById(‘buttonId’);
    button.style.display=’none’
  2. var button = document.getElementById(‘buttonId’);
    button.style.display=’block’
  3. var button = document.getElementById(‘btn’);
    button.style.visibility=’false’;
  4. var button = document.getElementById(‘btn’);
    button.style.visibility=’disabled’;
  5. None of these.

127. Why does (0 < 5 < 3) return true?

Answers:

  1. Order of operations produces (true < 3), which returns true.
  2. Order of precedence produces (true < 3), which returns true.
  3. Order of operations produces (false < 3), which returns true.
  4. None of these.

128. What is the cleanest, most effective way to validate decimal numbers in JavaScript?

Answers:

  1. IsNumeric()
  2. isNaN()
  3. valid()
  4. isDecimal()

129. Which of the following is the best reason for not using «for…in» with array iteration?

Answers:

  1. for..in should be used to iterate over an array where index order is important.
  2. for..in should not be used to iterate over an array where index order is important.
  3. for…in loops iterate over non–enumerable properties.
  4. for…in loops do not iterate over enumerable properties.

130. Which of the following is the best reason for not using «for…in» with array iteration?

Answers:

  1. It forces the parser to treat the + sign as a part of an expression.
  2. The + sign is used as a cast operator.
  3. It is used to denote a type of object in JavaScript.
  4. None of these.

131.Which of the following will implement a singleton pattern in JavaScript?

Answers:

  1. <script>
    var anObject = {
    method1: function () {
    // …<
    },
    method2: function () {
    // …
    }
    };
    ></script>
  2. <script>
    function method1(){
    // …
    }
    function method2(){
    // …
    }
    </script>
  3. <script>
    var method1 = function(){
    // …
    }
    var method2 = function(){
    // …
    }
    </script>
  4. <script>
    var method1;
    var method2;
    </script>

132. Which of the following code snippets will correctly detect a touchscreen device?

Answers:

  1. function isTouchDevice() {
    return !!(‘ontouchstart’ in window) || !!(‘onmsgesturechange’ in window);
    };
  2. function isTouchDevice() {
    try {
    document.body.createEvent(«TouchEvent»);
    return true;
    } catch (e) {
    return false;
    }
    }
  3. function isTouchDevice(){
    return (typeof(navigator.ontouchstart) != ‘undefined’) ? true : false;
    }
  4. function isTouchDevice(){
    return (navigator.msMaxTouchPoints == 0);
    }

133. Which of the following shows examples of valid auto increment/decrement loops?

Answers:

  1. for(var i=0; i < 100; i++){} for(var i=0; i > -100; i—){}
  2. for(var i=0; i < 100; i+){} for(var i=0; i > -100; i-){}
  3. for(var i=0; i > 100; i++){}
    for(var i=0; i < -100; i—){}
  4. for(var i=0; i > 100; i+){}
    for(var i=0; i < -100; i-){}

134. Analyze the following code snippet. What will be the output of this code?
<html>
<body>
<script type=»text/javascript»>
var str = «The drain of the plane is plain»;
var patt1 =/ain/g;
document.write(str.match(patt1));
</script>
</body>
</html>
Answers:

  1. a
  2. ain
  3. 7,29
  4. 7
  5. ain,ain

135.The following are sample codes on how to merge properties of two JavaScript objects dynamically:
var obj1 = { food: ‘pizza’, car: ‘ford’ }
var obj2 = { animal: ‘dog’ }
Which of the following are JavaScript codes?

Answer:

  1. obj1.merge(obj2);
  2. function MergeRecursive(obj1,obj2){
    var obj3 = {};
    for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
    for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
    return obj3;
    }
  3. function MergeRecursive(obj1, obj2) {
    for (var p in obj2) {
    try {
    // Property in destination object set; update its value.
    if ( obj2[p].constructor==Object ) {
    obj1[p] = MergeRecursive(obj1[p], obj2[p]);
    } else {
    obj1[p] = obj2[p];
    }
    } catch(e) {
    // Property in destination object not set; create it and set its value.
    obj1[p] = obj2[p];}
    }
    return obj1;
    }
  4. Object.extend = function(destination,source) {
    for (var property in source)
    destination[property] = source[property];
    return destination;
    }
    obj1.extend(obj2)

136.You need to be able to determine which page of the web site has been the most recently modified. Which object would enable you to do this?

Answers:

  1. document
  2. window
  3. history
  4. browser
  5. form
  6. location

137.Which of the following are the valid JavaScript codes to obtain the number of milliseconds since the epoch?
Note: There may be more than one right answer.

Answers:

  1. var timestamp = new Date().getTime();
  2. var timestamp = Number(new Date());
  3. var timestamp = Date.now;
  4. var timestamp = new Date().valueOf();

138.Which of the following ‘if’ statements is correctly used to get the size of both ‘variable1’ and ‘variable2’ objects?
var variable1 = {‘name’:’theName’, ‘address’:’theAddress’,’age’: ’18’}
var variable2 = [‘theName’,’theAddress’,’18’];

variable1[«name»] = «theName2»;
variable1[«name»] = «theName3»;
variable1[«name2»] = «theName4»;
variable1[«name2»] = «theName5»;

Object.size = function(importer) {
var exporter = 0, key;
for (key in importer) {
if (importer.hasOwnProperty(key)) exporter++;
}
return exporter;
};

Answers:

  1. if(typeof(variable1)==’object’ && typeof(variable2)==’array’){
    Object.size(variable1);
    variable2.length;
    }
  2. if(typeof(variable1)==’array’ && typeof(variable2)==’object’){
    Object.size(variable1);
    variable2.length;
    }
  3. if(typeof(variable1) > typeof(variable2)){
    Object.size(variable1);
    variable2.length;
    }
  4. if(typeof(variable1) == typeof(variable2)){
    Object.size(variable1);
    variable2.length;
    }

139.Consider the following JavaScript arrays:
var a = [1, 2];
var b = [3, 4, 5];
Which of the following will append the contents of array «b» to array «a»?

Answers:

  1. a.push(b);
  2. a.splice(0,0,b);
  3. a = b.concat(a);
  4. a.join(b);

140.How can it be determined if JavaScript is disabled in the user’s browser?

Answers:

  1. It is browser-dependent.
  2. There is no way to detect if JavaScript is disabled.
  3. Use the HTML<noscript> tag to display different content if JavaScript is disabled.
  4. None of these.

141.Which of the following choices shows the correct result for the code below? var arr = []; arr[0] = «Jani»; arr[1] = «Hege»; arr[2] = «Stale»; arr[3] = «Kai Jim»; arr[4] = «Borge»; console.log(arr.join()); arr.splice(2, 0, «Lene»); console.log(arr.join());

Answers:

  1. Jani,Hege,Stale,Kai Jim,Borge
    Lene,Jani,Hege,Stale,Kai Jim,Borge
  2. Jani,Hege,Stale,Kai Jim,Borge
    Jani,Hege,Lene,Stale,Kai Jim,Borge
  3. Jani,Hege,Stale,Kai Jim,Borge
    Jani,Hege,Stale,Kai Jim,Lene,Borge
  4. Jani,Hege,Stale,Kai Jim,Borge
    Jani,Hege,Stale,Kai Jim,Borge

142. Consider the following scenario:
The document.write() method is embedded to write some text within a pair of 

table tags. Upon loading the file, however, garbled text appears on the section of the page where the text should be. What could be the reason for this?

Answers:

  1. The browser does not support JavaScript.
  2. An older version of the browser is being used.
  3. The browser does not support cookies.

143. What is the output of the following code?
var a = 5;
var b = 1;
if(!!»false») {
a = a + 5;
b = 3;
};
if(!!0) {
a = a + 5;
b = b + 2;
};
alert(a+b);

Answers:

  1. 20
  2. 6
  3. None of these

144.Consider the following code:
var vNew=new Date()
Which of the following options will return true?

Answers:

  1. vNew instanceof boolean
  2. vNew instanceof boolean
  3. vNew instanceof Date
  4. All of these

145.Which of the following will detect if the browser supports a certain CSS property?

Answers:

  1. typeof document.body.style.borderRadius == ‘string’
  2. typeof document.body.style.borderRadius == ‘undefined’
  3. typeof document.body.style.borderRadius == true
  4. It is impossible.

146.Which of the following is not a valid code for redirect to stackoverflow.com?
Note: There may be more than one right answer.

Answers:

  1. window.location.href = «http://stackoverflow.com»;
  2. window.location.href («http://stackoverflow.com»);
  3. window.location.replace=»http://stackoverflow.com»;
  4. window.location.replace(«http://stackoverflow.com»);

147.The following statements show two ways of calling a JavaScript function:
i)onclick = «a();»
ii)onclick=»JavaScript:a();»
Which of the following options is correct, with regard to the two statements above?

Answers:

  1. There is no difference between the two statements
  2. The first statement is incorrect and the second one is correct.
  3. The first statement is correct and the second statement is incorrect.

148.Which of the following code snippets will trigger an input type=»file» attribute when an element with a «newbtn» ID is clicked?

Answers:
<button id»newbtn» onclick=»grt();»>Upload</button>
<form>
<input id=»thisId» type=»file» name=»upload» />
</form>
</form>

  1. function grt(){document.getElementById(‘thisId’).keypress();}
  2. function grt(){document.getElementById(‘thisId’).load();}
  3. function grt(){document.getElementById(‘thisId’).dblclick();}
  4. function grt(){document.getElementById(‘thisId’).click();}

149.Which of the following JavaScript code snippets is the more efficient and why?
Code Snippet 1
<script language=»javascript»>
for(i=0;i<document.images.length;i++)
document.images[i].src=»blank.gif»;
</script>
Code Snippet 2
<script language=»javascript»>
var theimages = document.images;
for(i=0;i<theimages.length;i++)
theimages[i].src=»blank.gif»;
</script>

Answers:

  1. Both codes are equally efficient.
  2. The first code is more efficient because it contains less code.
  3. The first code is more efficient because it employs object caching.
  4. The second code is more efficient because it employs object caching.

150.Which of the following cope samples will correctly search for the word «for» in a string?
Note: There may be more than one right answer.

Answers:

  1. var str=»This is test for javascript search !!!»;
    if(str.search(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }
  2. var str=»This is test for javascript search !!!»;
    if(str.indexof(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }
  3. var str=»This is test for javascript search !!!»;
    if(str.indexOf(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }
  4. var str=»This is test for javascript search !!!»;
    if(str.contains(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }

151.Given two frames Frame1 and Frame2, where Frame2 has a div element with id «some», how can the div element’s color be changed in Frame2, using JavaScript code in Frame1?

Answers:

  1. var div = top.Frame2.document.getElementById(‘some’);
    div.style.color= «orange»;
  2. var div = document.getElementById(‘some’);
    div.style.color= «orange»;
  3. var div = top.Frame1.document.getElementById(‘some’);
    div.style.color= «orange»;
  4. None of these.

152.Which of the following JavaScript Regular Expression character classes finds any non-digit character in a given string?

Answers:

  1. \W
  2. \S
  3. \B
  4. \D

153. Which best describes void?

Answers:

  1. A method
  2. A function
  3. A statement
  4. An operator
  5. A built-in object

154.Which of the following is used to solve the problem of enumerations in JavaScript?

Answers:

  1. let
  2. Regex
  3. Generators
  4. E4X

155.Which of the following cannot be achieved using JavaScript?
Note: There may be more than one right answer.

Answers:

  1. Read or write from external files (except .js files)
  2. Access or modify browser settings
  3. Launch client processes (eg windows applications)
  4. Launching the default email application of the client

156.The following are sample codes on how to loop through JavaScript object literals with objects as members:
var validation_messages = {
«key_1»: {
«your_name»: «jimmy»,
«your_msg»: «hello world»
},
«key_2»: {
«your_name»: «billy»,
«your_msg»: «foo equals bar»
}
}
Which of the following are invalid native JavaScript codes?
Note: There may be more than one right answer.

Answers:

  1. for (var key in validation_messages) {
    var obj = validation_messages[key];
    for (var prop in obj) {
    alert(prop + » = » + obj[prop]);
    }
    }
  2. Object.keys(validation_messages).forEach(function(key) {
    var obj = validation_messages[key];
    Object.keys(obj).forEach(function(key) {
    alert (prop + “ = “ + obj[key]);
    )};
  3. (validation_messages.hasOwnProperty(key)) {
    var obj = validation_messages[key];
    for (var prop in obj) {
    if (obj.hasOwnProperty(prop)) {
    alert(prop + “ = “ + obj[prop]);
    }
    }
    }
    }
  4. _.each(validation_messages, function(value, key){
    _.each(value, function(value, key){
    alert(prop + » = » + value);
    });
    });

157.Analyze the following code snippet. What will be the output of this code?
html>
<body>
<script type=»text/javascript»>
var str = «Visit Gardens(now)»;
var patt1 = new RegExp(«(now)», «g»);
patt1.test(str);
document.write(RegExp.lastParen);
</script>
</body>
</html>
Answers:

  1. now
  2. (now)
  3. 15
  4. 19

158.Consider the following code:
var variable=2*2+10000/10-133%5;
Which of the following combinations have the lowest operator precedence in «variable»?

Answers:

  1. «*» and «+»
  2. «/» and «%»
  3. «/» and «+»
  4. «*» and «%»

159.While coding a loop, you come across a condition where you have to terminate the loop and continue with the statements following the loop. Which statement would you use?

Answers:

  1. exit
  2. return
  3. continue
  4. while
  5. break

160. What is the best way to make optional parameters of functions?

Answers:

  1. function someFunction(requiredArg, optionalArg) {
    optionalArg = optionalArg || ‘defaultValue’;
    alert(optionalArg);
    }
  2. function someFunction(requiredArg, optionalArg) {
    optionalArg = (typeof optionalArg === «undefined») ? «defaultValue» : optionalArg;
    alert(optionalArg);
    }
  3. function someFunction(requiredArg, optionalArg) {
    optionalArg = (optionalArg === «undefined») ? «defaultValue» : optionalArg;
    alert(optionalArg);
  4. All of these

161. Which of the following are correct closure functions?

Answers:

  1. function foo(x) {
    var tmp = 3;
    return function (y) {
    alert(x + y + (++tmp));
    }
    }
    var bar = foo(2); // bar is now a closure.
    bar(10);
  2. function foo(x) {
    var tmp = 3;
    function bar(y) {
    alert(x + y + (++tmp));
    }
    bar(10);
    }
    foo(2)
  3. function foo(x) {
    var tmp = 3;
    function bar(y) {
    function bar1(tmp) {
    alert(x + y + (++tmp));
    }
    }
    bar(10);
    }
    foo(2)
  4. function foo(x) {
    var tmp = 3;
    return function (y) {
    alert(x + y + tmp);
    x.memb = x.memb ? x.memb + 1 : 1;
    alert(x.memb);
    }
    }
    var age = new Number(2);
    var bar = foo(age); // bar is now a closure referencing age.
    bar(10);

162.Which of the following will correctly detect browser language preference?

Answers:

        1. var language = window.navigator.userLanguage || window.navigator.language;
          alert(language);
        2. var language = navigator.browserLanguage || window.navigator.language;
          alert(language);
        3. var language =navigator.userLanguage;
          alert(language);
        4. var language = window.navigator.language;
          alert(language);

163.What is the output of the following code?
var container = {
someKey: 3,
someOtherKey: “someObject”,
anotherKey: “Some text”
};
if (“someOtherKey” in container) {
alert (true);
}
delete container [“someOtherKey”];
if (container[“someOtherKey”] === null) {
alert (false);
}
if (container[“someOtherKey”] === undefined) {
alert (true);
}
if (container.someOtherKey === undefined) {
alert (false);
}
if (container.someOtherKey === undefined) {
alert (true);
}
delete container[“someKey”];
if (container.someKey === 3) {
alert (true);
}
Answers:

        1. true
          true
          false
        2. true
          true
          true
        3. true
          false
          true
          false
          true
          true
        4. true
          true
          false
          true

164. Which of the following is a good reason why JavaScript variables would start with a dollar sign ($)?

Answers:

        1. $ is a prefix used to create a instance of a object.
        2. $ is a keyword in JavaScript.
        3. $ is used to quickly identify and parse variables
        4. None of these

165.Which of the following code is correct for validating date values?
Note: There may be more than one right answer.

Answers:

        1. var d = Date.parse(‘foo’);
          if (isNaN(d)==false)
          {
          alert(new Date(d));
          } else {
          alert(‘Invalid date’);
          }
        2. var d = new Date(‘foo’);
          if (d instanceof Date && isFinite(d))
          {
          alert(d);
          } else {
          alert(‘Invalid date’);
          }
        3. Date.prototype.valid = function() {
          return isFinite(this);
          }
          var d = new Date(‘foo’);
          if (d.valid())
          {
          alert(d);
          } else {
          alert(‘Invalid date’);
          }
        4. All of the above

166. Which of the following correctly explains the difference between a «for…in» and a «for» loop?

Answers:

        1. «for…in» has two expressions. It iterates over the enumerable properties of an object, in an arbitrary order, for each distinct property, statements can be executed. This should not be used to iterate over an array where index order is important.
          «for» consists of three optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
        2. «for…in» has three expressions. It iterates over the enumerable properties of an object, in an arbitrary order, for each distinct property, statements can be executed. This should not be used to iterate over an array where index order is important.
          «for» consists of four optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
        3. «for…in» iterates over the enumerable properties of an object, in an arbitrary order, for each distinct property, statements can be executed. This should be used to iterate over an array where index order is important.
          «for» consists of three optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
        4. «for…in» iterates over the enumerable properties of an object, in arbitrary order, for each distinct property, statements can be executed, this should be used to iterate over an array where index order is important.
          «for» consists of two optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.

167.Which of the following will list the properties of a JavaScript object?

Answers:

      1. var keys = Object.keys(myJsonObject);
      2. var keys = Object.value(myJsonObject)
      3. var keys = Object.keys(myJsonValue)
      4. None of these

17,507 total views, 284 views today

Top 10 popular test answers

HTML5 Test

Published by:

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

Answers:

  1. It communicates with the server with only the data required by the application.
  2. It lowers the latency of connections for interactive web applications.
  3. It scales better and consumes less server resources than HTTP AJAX/long-poll.
  4. All of the above.

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

  1. var context = canvas.getContext();
  2. var context = canvas.getElementById(“context”);
  3. var context = canvas.getContext(“2d”);
  4. var context = canvas.getElementById(“2d”);

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

Answers:

  1. It is used to define important text.
  2. It is used to define computer code text.
  3. It is used to define sample computer code.
  4. It is used to define a definition term.

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

Answers:

  1. <object> <param name=”allowFullScreen” value=”true” />
  2. <video allowFullScreen=”true”>
  3. <video height=”100%” width=”100%”>
  4. None of these.

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

  1. 89
  2. 90
  3. Item 1
  4. Item 2

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

Answers:

  1. Drag and drop files from the desktop
  2. Full file system access
  3. Use of the HTML5 File API
  4. Use of files as HTML5 input types

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

Answers:

  1. _blank
  2. _self
  3. _top
  4. _bottom

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

Answers:

  1. An input tag button can be a reset button too.
  2. A button tag button can be a reset button too.
  3. An input tag button can include images as well.
  4. A button tag can include images as well.

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

Answers:

  1. toDataURL()
  2. saveAsImage()
  3. saveFile()
  4. exportImage()

10. Can we store JavaScript Objects directly into localStorage?

Answers:

  1. Yes
  2. No

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

Answers:

  1. It gets fired when an element has been dragged to a valid drop target.
  2. It gets fired when an element leaves a valid drop target.
  3. It gets fired at the end of a drag operation.
  4. It gets fired while an element is being dragged.

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

Answers:

  1. The application cache is programmatically updated.
  2. The application cache gets automatically cleared by the browser.
  3. The manifest file is modified.
  4. The user clears their browser’s data storage for the site.

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

Answers:

  1. DD-MM-YYYY
  2. YYYY-MM-DD
  3. MM-DD-YYYY
  4. YYYY-DD-MM

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

Answers:

  1. <link rel=”icon” href=”abc.jpg” sizes=”16×16″>
  2. <link rev=”stylesheet” href=”abc.css” type=”text/css” target=”_parent”>
  3. <link rel=”alternate” type=”application/pdf” hreflang=”fr” href=”manual-fr”>

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

Answers:

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

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

Answers:

  1. var video = document.getElementsByTagName(‘video’)[0]; video.onended = function(e) { }
  2. var video = document.getElementsByTagName(‘video’)[0]; video.onPlayend = function(e) { }
  3. var video = document.getElementsByTagName(‘video’)[0]; video.onPlayFinish = function(e) { }
  4. var video = document.getElementsByTagName(‘video’)[0]; video.onPlayBackended = function(e) { }

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

Answers:

  1. WebSockets can perform bi-directional (client-server and vice versa) data transfers, while SSEs can only push data to the client/browser.
  2. SSEs can perform bi-directional (client-server and vice versa) data transfers, while WebSockets can only push data to the client/browser.
  3. WebSockets and SSEs are functionally equivalent.
  4. None of these.

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

Answers:

  1. Using _gaq.push([‘_trackPageLoadTime’]) with Google Analytics.
  2. Using the Navigation Timing JavaScript API.
  3. Page load times cannot be estimated.
  4. Using built-in JavaScript methods.

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

Answers:

  1. <tr class=”foo” data-id-type=”4″>
  2. <tr class=”foo” id-type=”4″>
  3. <tr class=”foo” data-id_type=”4″>
  4. All of the above.

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

Answers:

  1. #myCanvas {height: 100%; width: 100%;}
  2. <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>
  3. It depends upon the complexity of the canvas, and the frequency of redraws.
  4. Calling the JavaScript getWidth() function.

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

Answers:

  1. toDataURL
  2. toImageURL
  3. saveAsPNG
  4. saveAsJPEG

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

Answers:

  1. localStorage.setItem(‘obj’, obj);
  2. localStorage.setItem(‘obj’, JSON.stringify(obj));
  3. localStorage.setItem(‘testObject’, JSON.parse(testObject));
  4. localStorage.setItem(obj);

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

  1. var context = canvas.getContext();
  2. var context = canvas.getElementById(“context”);
  3. var context = canvas.getContext(“2d”);
  4. var context = canvas.getElementById(“2d”);

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

Answers:

  1. input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
  2. input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  3. noindex:-o-prefocus, input[type=number] { padding-right: 1.2em; }
  4. input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; padding-right: 1.2em; }

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

Answers:

  1. <input type=”text” pattern=”[0-9]*” />
  2. <input type=”number” />
  3. <input type=”text” pattern=”d*”/>
  4. <input type=”text” pattern=”number”/>

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

Answers:

  1. <object type=”application/pdf” data=”filename.pdf” width=”100%” height=”100%”/>
  2. <object type=”application/pdf” id=”filename.pdf” width=”100%” height=”100%”/>
  3. <input type=”application/pdf” data=”filename.pdf” width=”100%” height=”100%”/>
  4. <input type=”application/pdf” src=”filename.pdf” width=”100%” height=”100%”/>

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

Answers:

  1. isCanvasSupported()
  2. !!document.createElement(“canvas”)
  3. !isCanvasSupported()
  4. !!window.HTMLCanvasElement

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

Answers:

  1. onstalled
  2. onwaiting
  3. onsuspend
  4. oninvalid

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

Answers:

  1. console.log(WebSocket ? ‘supported’ : ‘not supported’);
  2. console.log(window.WebSocket ? ‘supported’ : ‘not supported’);
  3. console.log(window[WebSocket] ? ‘supported’ : ‘not supported’);
  4. console.log(window[‘WebSocket’] ? ‘supported’ : ‘not supported’);

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

Answers:

  1. CCTV
  2. MPEG 4
  3. Ogg
  4. 3GPP

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

Answers:

  1. <input name=”username” required /> <input name=”pass” type=”password” required/>
  2. <input name=”username” validate=”true”/> <input name=”pass” type=”password” validate=”true”/>
  3. <input name=”username” validate/> <input name=”pass” type=”password” validate/>
  4. There is no way to implement client-side validation for the username and password fields in HTML5.

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

Answers:

  1. controls
  2. autoplay
  3. disabled
  4. preload

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

  1. ctx.drawImage(img,10,10);
  2. context.drawImage(img,20,10,10,10);
  3. context.drawImage(img,10,20,10,10,20,20,10,10);
  4. All of these

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

Answers:

  1. localStorage.setItem(‘testObject’, JSON.stringify(testObject))
  2. localStorage.setItem(‘testObject’, testObject)
  3. localStorage.add(‘testObject’, testObject)
  4. localStorage.addItem(‘testObject’, testObject)

35. How can audio files be played in HTML5?

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

Answers:

  1. sound.begin();
  2. sound.resume();
  3. sound.start();
  4. sound.play();

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

Answers:

  1. var snd = new Audio(“file.wav”); snd.play();
  2. <audio controls> <source src=”file.ogg” type=”audio/ogg”> <source src=”file.mp3″ type=”audio/mpeg”> </audio>
  3. <source src=”file.mp3″ type=”audio/mpeg”>
  4. All of these.

37. Which HTML5 doctype declarations are correct?

Answers:

  1. <!doctype html>
  2. <!DOCTYPE html>
  3. <!DOCTYPE HTML5>
  4. <!DOCTYPE HTML>

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

  1. <a href=”mailto:webmaster@xcompany.com”>webmaster</a>
  2. <a href=”webmaster@xcompany.com”>webmaster</a>
  3. <a http=”mail:webmaster@xcompany.com”>webmaster</a>
  4. <mail http=”send:webmaster@xcompany.com”>webmaster</mail>

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

Answers:

  1. Polling URLs in background
  2. Syntax highlighting without blocking code editing capabilities in online IDEs
  3. Motion tracking input in realtime with a video element
  4. All of these.

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

Answers:

  1. onerror
  2. onended
  3. onloadeddata
  4. onemptied

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

  1. accept
  2. autofocus
  3. autocomplete
  4. formtarget

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

Answers:

  1. Server-Sent Events
  2. SVG
  3. Canvas
  4. Web Workers

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

Answers:

  1. Every HTML element can have an ARIA role attribute specified.
  2. Every HTML element is required have an ARIA role attribute specified.
  3. 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.
  4. There is no ARIA attribute called “role”.

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

Answers:

  1. play
  2. loop
  3. mute
  4. pause

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

Answers:

  1. True
  2. False

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

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

 

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

  1. It will open the site msdn.com in the same window.
  2. It will open the site msdn.com in a new window.
  3. It will open the site msdn.com in a frame below.
  4. It will not be clickable as it is not formed correctly.

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

Answers:

  1. now
  2. 2013-05-30
  3. 2013-30-05
  4. today

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

Answers:

  1. True
  2. False

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

Answers:

  1. 65536
  2. 64
  3. There is no limit.
  4. None of these.

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

Answers:

  1. foo & bar
  2. foo &0 bar
  3. foo &0; bar
  4. foo&&& bar

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

Answers:

  1. context.clearRect ( x , y , w , h );
  2. canvas.width = canvas.width;
  3. context.clear();
  4. All of these.

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

Answers:

  1. sizes
  2. rev
  3. rel
  4. charset

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

  1. button
  2. command
  3. checkbox
  4. radio

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

  1. autocomplete
  2. autofocus
  3. placeholder
  4. formnovalidate

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

Answers:

  1. onfocus
  2. onload
  3. onblur
  4. onselect

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

Answers:

  1. It is used to define the start of a term in a definition list.
  2. It is used to define attribute values for one or more columns in a table.
  3. It is used to define the start of a short quotation.
  4. It is used to define what to show browsers that do not support the ruby element.

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

  1. 89
  2. 90
  3. Item 1
  4. Item 2

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

Answers:

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

60. Which of the following are valid HTML5 elements?

Ans:

  1. canvas
  2. summary
  3. aside
  4. video

61. Which of the following are possible ways to make the browser automatically adds new images and discards deleted images with server-side events in HTML5?

Ans:

  1. Long Polling Ajax Requests
  2. Server-sent Events
  3. WebSockets
  4. JavaScript objects on the client via JSON.parse().

62. Which of the following input element variations will show a numeric keypad in mobile browsers?

Ans: 

  1. <input type=”text” pattern=”[0-9]*” />
  2. <input type=”number” />
  3. <input type=”text” keyboard=”numeric” />
  4. <input type=”text” keyboard=”number11″ />

63. Which of the following elements have the correct attribute assignment as per HTML5?
Ans:

a. <section id=”example”>…</section id=”example”>
b. <section id=”example”>…</section id=”example2″>
c. <section id=”EXAMPLE”>…</section>
d. <section id=”Example”>…</section>
e. <section id=”example”>…</section>

64. True or false:

JavaScript objects can be stored directly into localStorage.

Ans: 

  1. True
  2. False

65. What is the proper syntax for a line break tag as W3C specs defines?.

Ans: 

  1.   <br>
  2. </br>
  3. <br/>
  4. All of these

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

Ans: 

  1. <tr class=»foo» data-id-type=»4″>
  2.  <tr class=»foo» id-type=»4″>
  3. <tr class=»foo» data-id_type=»4″>
  4. All of the above.

67.Which of the following elements have the correct attribute assignment as per HTML 5.0?

Ans:

  1. <section id=»example»>…</section id=»example»>
  2. <section id=»example»>…</section id=»example2″>
  3. <section id=»EXAMPLE»>…</section>
  4. <section id=»Example»>…</section>
  5. <section id=»example»>…</section>

68.What does the icon attribute of the HTML5 command tag define?
<command icon=»?»>Click Me!</command>
Ans: 

  1. It is used to define the URL of an image to display as the command.
  2. It is used to define the name of the radiogroup this command belongs to.
  3. It is used to define if the command is checked or not.
  4. It is used to define if the command is available or not.

69.Which of the following methods are valid for navigating to a fragment identifier?

http://demo.com/#foo

Note: There may be more than one right answer.
Ans: 

  1. <a name=»foo»>bar</a>;
  2. <a id=»foo»>bar</a>
  3. <div id=»foo»>bar</div>
  4. <div class=»foo»>bar</div>

70.Which of the following events is not supported in HTML5?

Ans: 

  1. oninput
  2. oninvalid
  3. ondrop
  4. onrest

71.Which of the following is an invalid value for the type attribute of a command tag?

Ans: 

  1. checkbox
  2. radio
  3. command
  4. text

72.Which of the following are true regarding the <keygen> tag in HTML5? 

Ans: 

  1. The <keygen> tag specifies a key-pair generator field used for forms.
  2. The <keygen> tag generates a public/private key pair and then creates a certificate request. This certificate request will be sent to a Certificate Authority (CA), which then creates a certificate and sends it back to the browser.
  3. The <keygen> tag generates random passwords when the user requests for a password reset.
  4. The <keygen> tag is deprecated in HTML5.

73. Which of the following is not an attribute of theelement in HTML5?

Ans: 

  1. charset
  2. content
  3. http-equiv
  4. scheme

74.Which of the following is a proper syntax for
tag as W3C specs for HTML5 defines?

Ans: 

  1. <br/>
  2. <br/>
  3. <br>
  4. <br></br>

74.What does the icon attribute of the HTML5 command tag define?
Click Me!

Ans: 

  1. It is used to define the URL of an image to display as the command.
  2. It is used to define the name of the radiogroup this command belongs to.
  3. It is used to define if the command is checked or not.
  4. It is used to define if the command is available or not.

75.Which of the following input element variations will show a numeric keypad in mobile browsers?

Ans: 

  1. <input pattern=”[0-9]*” type=”text” />
  2. <input type=”number” />
  3. <input type=”text” />
  4. <input type=”text” />

76.Which of the following is not a method of WebSQL Database API?

Ans: 

  1. openDatabase.
  2. transaction.
  3. executeSql.
  4. connect.

77.Which of the following is not a valid control in HTML5?

Ans: 

  1. range.
  2. url
  3. address
  4. number

78.Which one of the following is not a valid input control in HTML5?

Ans: 

  1. range.
  2. url
  3. address
  4. number

79.Play Audio Loop using the following example?

Ans: 

  1. audio=new Audio(‘asound.ogg’);
    audio.addEventListener(‘ended’,function(){
    this.currentTime=0;
    this.play();
    },false);
    audio.play();
  2. audio=newAudio(‘someSound.ogg’);
    if(typeof audio.loop==’boolean’)
    {
    audio.loop=true;
    }
    else
    {
    audio.AddEventListener(‘loop’,function(){
    this.currentTime=1;
    this.autoplay();
    },false);
    }
    audio.play();
  3. audio=new Audio(‘asound.ogg’);
    audio.addEventListener(‘loop’,function(){
    this.currentTime=1;
    this.autoplay();

80.Which of these elements are deprecated in HTML5?

Answers:

  1. <center >
  2. <font>
  3. <iframe>
  4. <tfoot >

81.Which method is used to fetch the current geographic location of the user and update it as a user moves?

Answers:

  1. getCurrentPosition()
  2. watchPosition()
  3. getContinousPosition()
  4. watchContinuousPosition()

82.The element to specify a list of predefined options for input control is

Answers:

  1. <source >
  2. <datalist>
  3. <tracklist>
  4. <toptionlist >

83.Which of the following method is used to check if the browser can play the specified audio/video

Ans: 

  1. checkType
  2. canplayType
  3. typesupport
  4. mediaPlayType

84.Drawing text, The canvas context provides following method to render the text?

Ans: 

  1. fileText(text,x,y[,maxwidth])
  2. fileText(text,x,y{,maxwidth})
  3. strokeText(text,x,y{,maxwidth})
  4. strokeText(text,x,y[,maxwidth])

85.What is used to continously push events from the web server to the client’s browser?

Ans: 

  1. Server Sent Events
  2. Web Workers
  3. AJAX
  4. Push Notifications

86.Which of the following attributes requires you to have a value in an input control in HTML5?

Ans: 

  1. autofoucs
  2. required
  3. placehlder
  4. output

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

Ans: 

  1. preload
  2. loop
  3. stopped
  4. muted

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

Answers:

  1. <background >red</background>
  2. <body bg=”red”>>
  3. <body style=”background-color:red;”>

89.Which method is used to finish a launched worker?

Ans: 

  1. endWorker
  2. terminate
  3. finish

90.Which of the following is a new input type introduced in HTML5?

Ans: 

  1. text
  2. password
  3. email
  4. radio

91.How can audio files be played in HTML5?

Ans: 

  1. var sound=new Audio(“file.wav”);
  2. sound.begin ( );
  3. sound.resume ( );
  4. sound.start ( );
  5. sound.play ( );

92.Which of these elements are deprecated in HTML5?

Answers:

  1. <object type=”application/pdf” data=”filename.pdf” widh=”100%” height=”100%” >
  2. <object type=”application/pdf” id=”filename.pdf” widh=”100%” height=”100%”>
  3. <input type=”application/pdf” data=”filename.pdf” widh=”100%” height=”100%”>
  4. <input type=”application/pdf” source=”filename.pdf” widh=”100%” height=”100%”>

93.Which of the following staement is correct about Server-Side image maps?

Ans: 

  1. This is enabled by the ismap attribute of the < img > tag and required access to the server and related image-map processing applications
  2. This is created with the usemap attribute of the < img > tag, along with corresponding <map> and <div>tags
  3. This is created with the image attribute of the < img> tag, along with corresponding image < map> and
    data < area>
  4. None of the above

94.Which element defines the title of a work(e.g. a book, a song, a movie, etc.)?

Answers:

  1. <details >
  2. <font>
  3. <cite>
  4. <bdi >
  5. <title>

95.Which method is used to execute a query in WebSQL?

Ans: 

  1. execute
  2. execute WebSQL
  3. executeSQL
  4. executeQuery

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

Ans: 

  1. DD-MM-YYYY
  2. YYYY-MM-DD
  3. MM-DD-YYYY
  4. YYYY-DD-MM

97. Which of the following elements have the correct attribute assignment as per HTML5?
Ans:

a. <section id=»example»>…</section id=»example»>
b. <section id=»example»>…</section id=»example2″>
c. <section id=»EXAMPLE»>…</section>
d. <section id=»Example»>…</section>
e. <section id=»example»>…</section>

98. Which of the following is not an attribute of the element in HTML5?

Answers:

  1. charset
  2. content
  3. http-equiv
  4. scheme

99.Which of the following is a proper syntax for
tag as W3C specs for HTML5 defines?

Ans: 

  1. <br/>
  2. <br/>
  3. <br>
  4. <br></br>

100.Can we use SVG tags directly in HTML5 without using any plugin?

Answers:

  1. Yes
  2. No

101. Which of the following elements have the correct attribute assignment as per HTML5?
Ans:

    a.<div class=»one,two,three»></div>
    b.<div class=»one;two;three»></div>
    c.<div class=»one two three»></div>
    d.<div class=»one» class=»two» class=»three»></div>

102.How to make an element draggable in HTML5?

Answers:

  1. set the draggable attribute to true as draggable=»true»
  2. set the movable attribute to true as movable=»true»
  3. set the dropable attribute to true as dropable =»true»
  4. You can not make an element draggable in HTML5

103.Which of the following is not a core method of WebSQL Database API?

Answers:

  1. openDatabase
  2. transaction
  3. executeSql
  4. connect

104.Which element defines the title of a work (e.g. a book, a song, a movie, etc.)?

Ans: 

  1. <details>
  2. <cite>
  3. <bdi>
  4. <title>

105.The HTML5 element used to draw a graphics via scripting?

Answers:

  1. mark
  2. figure
  3. Canvas
  4. figcaption

106.Which value of Socket.readyState atribute of WebSocket indicates that the connection is going through the closing handshake?

Answers:

  1. 0
  2. 1
  3. 2
  4. 3

107.How to declare HTML5 document type?

Ans: 

  1. <!DOCTYPE html5>
  2. <!DOCTYPE html>
  3. <!DOCTYPE HTML PUBLIC «-//W3C//DTD HTML 5.00 Transitional//EN» «http://www.w3.org/TR/html5/loose.dtd»>
  4. <!DOCTYPE HTML PUBLIC VERSION «5.00»>

108.Is WebSQL a part of HTML5 specification?

Answers:

  1. Yes
  2. No

109.Which of these statements are considered as best practices?

Answers:

  1. Place all CSS/ JavaScript files within the <head> element
  2. Place all CSS/ JavaScript files at the bottom of <body> element
  3. Place CSS files within the <head > element
  4. Place JavaScript files at the bottom of <body> element

110. In HTML5, drag and drop is part of the standard?

Answers:

  1. True
  2. False

111. Which of the following attribute triggers an abort event?

Answers:

  1. abort
  2. offline
  3. onabort
  4. onbeforeonload

112. Which is the following represents that the document is using HTML5?

Ans: 

  1. <!DOCTYPE HTML PUBLIC «-//W3C//DTD HTML 4.01//EN» «http://www.w3.org/TR/html4/strict.dtd»>
  2. <!DOCTYPE HTML PUBLIC «-//W3C//DTD HTML 4.01 Transitional//EN» «http://www.w3.org/TR/html4/loose.dtd»>
  3. <!DOCTYPE html PUBLIC «-//W3C//DTD XHTML 1.0 Strict//EN» «http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd»>
  4. <!DOCTYPE html>

113. Which of the following attribute triggers an abort event?

Answers:

  1. fillStyle()
  2. fill()
  3. color()
  4. fillColor()

114. How do you specify where the dragged data can be dropped?

Answers:

  1. Setting attribute dropable = «true»
  2. Calling the event.preventDefault() method for the ondragover event.
  3. Setting attribute draggable = «true»
  4. Calling the event.preventDefault() method for the ondragstart event.

115. Which of the following video formats is not supported by the video tag?

Answers:

  1. MP4
  2. WebM
  3. color()
  4. Ogg
  5. Mov

116. Which tag is used to show subtitles in a video in HTML5?

Answers:

  1. track
  2. source
  3. video
  4. audio

117. Which methods are provided by geolocation?

Answers:

  1. getCurrentPosition
  2. watchPosition
  3. clearWatch
  4. All of the above

118. Which of the following tag can be used to associate a caption together with some embedded content in HTML5?

Answers:

  1. caption
  2. figure
  3. nav
  4. dialog

119. Which attribute specifies that the video will be loaded at page load, and ready to run. Ignored if autoplay is present.

Answers:

  1. poster
  2. loop
  3. preload
  4. src

120. How do you declare HTML5 document type?
Ans: 

  1. <!DOCTYPE html5>
  2. <!DOCTYPE html>
  3. <!DOCTYPE HTML PUBLIC «-//W3C//DTD HTML 5.00 Transitional//EN» «http://www.w3.org/TR/html5/loose.dtd»>
  4. <!DOCTYPE HTML PUBLIC VERSION «5.00»

121. Which of the following code is valid?
Ans:

a. <div id=»container» class=»home-page» datasize=»960px»>< /div>
b. <div id=»#container» class=».home-page» data-size=»960px»></div>
c. <div id=»container» class=»home-page» data-size=»960px»></div>
d. <All of these codes are valid>

122.Which tag in HTML5 can be used to define navigation links?

Answers:

  1. navigation
  2. footer
  3. nav
  4. meter

123. Which among the following tags define a caption for a fieldset element?
Answers:

  1. egend
  2. select
  3. input
  4. textarea

124. Which of the following attribute triggers event when an element gets user input?

Answers:

  1. oninput
  2. ondata
  3. onput
  4. onhaschange

125.Which of the following tags used to specify subtitles for <video>?
Answers:

  1. <sub>
  2. <title>
  3. <subtitle>
  4. < track>

126. Which tags are most commonly used by search engines?

Answers:

  1. Paragraph
  2. Heading Correct
  3. Title
  4. All of above

127.Which of the following is not a valid input type of the form tag?

Answers:

  1. email
  2. checkbox
  3. hidden
  4. video

128.What is the correct HTML5 element for playing video files?

Ans: 

  1. <movie>
  2. <media>
  3. <video>
  4. All of the above

129.Why should you add alternative text to your images?

Answers:

  1. In case the user wishes to load a different picture
  2. So the users can get an idea of what the image is before it loads and it is also helpful in SEO
  3. So the user can save the image using the text as a name
  4. Just to keep your document valid

129.The way the browser displays the object can be modified by

Answers:

  1. attributes
  2. parameters
  3. modifiers
  4. None of above

130.When using video on a page, if autoplay attribute is set then which of the following attributes is ignored?

Answers:

  1. loop
  2. preload
  3. controls
  4. muted

131. What is used to continuously push events from the web server to the client’s browser?

Answers:

  1. Server Sent Events
  2. Web Workers
  3. AJAX
  4. Push

132.Which of the following event occurs when the document comes online?

Answers:

  1. onload
  2. onloadstart
  3. onmessage
  4. ononline

133.Which is the recommended standard video format in HTML5?

Answers:

  1. Theora video and Vorbis audio, as well as the Ogg container format.
  2. The HTML5 specification does not specify which video and audio formats browsers should support.
  3. H.264/MPEG-4 AVC

134.Which method is used to fetch the current geographic location of the user and update it as the user moves?

Answers:

  1. getCurrentPosition()
  2. watchPosition()
  3. getContinuousPosition()
  4. watchContinuousPosition()

135.Which of the following input control accepts only numerical value in HTML5?

Answers:

  1. range
  2. number
  3. time
  4. week

136.How many h1 elements are recommended on a single page?

Answers:

  1. Unlimited.
  2. One per section (HTML5) or one per document (HTML4).
  3. Depends on the size of the page.

138. Which of the following input control is provided by HTML5 for input fields that should contain an e-mail address?

Answers:

  1. url
  2. email
  3. email-address

139.What is the correct HTML for making a checkbox?

Answers:

  1. <input type=»checkbox»>
  2. <check>
  3. <input type=»check»>
  4. <checkbox >

140. Which of the following is a new input restriction introduced in HTML5?

Answers:

  1. disabled
  2. maxlength
  3. readonly
  4. required

141. HTML tags are used to describe document ____?

Answers:

  1. Image
  2. Content
  3. Definition
  4. Groups

142.To specify a font for your whole page add which tag?

Answers:

  1. <defaultfont>
  2. <targetfont>
  3. <basefont>
  4. < body >

143. The background image will scroll when the user scrolls down the page, unless you add which property to the body tag ?

Answers:

  1. bgproperties=»stationary»
  2. bgproperties=»fixed»
  3. bgproperties=»holdstill»
  4. bgproperties=»scroll»

144. Which of the following method is used to import external scripts?Which of the following method is used to import external scripts?

Answers:

  1. import
  2. importScripts
  3. scriptsImport
  4. importJS

145. Which of the following creates an email address hyperlink?

Answers:

  1. <a href=»me@domainname.com»>Email me</a>
  2. <a href=»mailto:me@domainname.com»>Email me</a>
  3. <a href=»email:me@domainname.com»>Email me</a>
  4. <a href=»send:me@domainname.com»>Email me</a>

146. When images are used as links they get a blue border?

Answers:

  1. Type
  2. Never
  3. Unless border is set to zero
  4. Always

147. Which attribute specifies that the image is part of a server-side image-map?

Answers:

  1. IMAP
  2. SMAP
  3. ISMAP
  4. imageMap

148. Please select the correct media attributes of the style element:

Answers:

  1. all
  2. printscreen
  3. not phone and (color)
  4. speech and (min-device-width: 800px)

149. Which of these statements are true?

Answers:

  1. A block-level element always starts on a new line and takes up the full width available.
  2. An inline element does not start on a new line and only takes up as much width as necessary.
  3. A block-level element always starts on a new line and only takes up as much width as necessary.
  4. A block-level element can be placed into inline elements.

150. The default character encoding in HTML5 is?

Answers:

  1. UTF-16
  2. UTF-8
  3. UTF-32
  4. ISO-8859-1

151. Please select the correct usage of the address element:

Answers:

  1. <address>Last Modified: 2016/05/12 21:32:56</address>
  2. <footer>
  3. <address>
  4. Feel free to contact me at
  5. <a href=»mailto:johns@upwork.com»>John Smith</a>
  6. <p><mall>© copyright 2016 Upwork.</small></p>
  7. </address>
  8. </footer>
  9. <address>
  10. Feel free to contact me at
  11. <a href=»mailto:johns@upwork.com»>John Smith</a>
  12. </address>
  13. <p><mall>© copyright 2016 Upwork.</small></p>

152.To specify a font for your whole page add which tag?

Answers:

  1. <tfoot>
  2. <th>
  3. <col>
  4. < tcol >

153.How many tags are in a regular element?
Ans:

  • 1
  • 2
  • 3
  • 4

154. Which of the following code is valid?
Ans:

a. <div data=»{ ‘key’:’value’ }»>< /div>
b. <div data-key=»value»></div>
c. <div data_key=»value»></div>
d. <div key=»value»></div>

155. Which of the following is a new form element introduced in HTML5?

Answers:

  1. button
  2. textarea
  3. datalist
  4. select

156.Which of the following is/are valid HTML5 attributes?

Answers:

  1. webgl
  2. spellcheck
  3. manualfocus
  4. contextmenu

157. Which HTML tag is NOT used when formatting text?

Answers:

  1. <img>
  2. <small>
  3. <p>
  4. < strong >

158.Which of these values are allowed for attribute “method” for form element?

Answers:

  1. get
  2. post
  3. patch
  4. delete

159. Which of these elements are block-level?

Answers:

  1. <h1>…<h6>
  2. <p>
  3. <img>
  4. < span >

160.Which of these values are allowed for attribute “method” for form element?

Answers:

  1. Text displayed when you hold your mouse over an image
  2. Text displayed when an image is not found
  3. Text displayed when a user has images switched off in the browser
  4. All of the above

161. How do you make the content inside an element editable?

Answers:

  1. Setting the attribute contenteditable = «true»
  2. Setting the attribute editable = «true»
  3. Setting the attribute content = «editable»
  4. The content inside all the elements is editable by default in HTML5.

162. Which of these elements are block-level?

Answers:

  1. <list>
  2. <input type=»list»>
  3. <input type=»dropdown»>
  4. < select >

163.A 6 digit Hex color (#FF9966) defines values of Red, Blue and Green in which order ?

Answers:

  1. #BBRRGG
  2. #BBGGRR
  3. #RRGGBB
  4. #RRBBGG

164.Using Hspace will add what to your image?

Answers:

  1. Space to the left and right
  2. Space to the right and left
  3. Height to all equal
  4. Space to top and left

165.Which of the following is not valid about MediaRecorder API ?

Answers:

  1. MediaRecorder.start() method is called to start the recording.
  2. MediaRecorder.process() method is called to start the recording.
  3. MediaRecorder API works alongside Navigator.getUserMedia() to capture media data.
  4. The contents of the recording will be made available in the platform’s default encoding via the dataavailable event

166.Which of the following method is used to check if the browser can play the specified audio/video type?

Answers:

  1. checkType
  2. canPlayType
  3. typeSupport
  4. mediaPlayType

167.Which of the following method is used to check if the browser can play the specified audio/video type?

Answers:

  1. contenteditable
  2. height
  3. id
  4. name
  5. spellcheck
  6. translate
  7. value

168.Which of the following tag is used for a multi line text input control?

Answers:

  1. textarea
  2. textml
  3. text
  4. None of the above

169.Which of the following attribute specifies whether or not a user is allowed to drag an element?

Answers:

  1. draggable
  2. context
  3. content
  4. drag

23,798 total views, 23 views today