wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Coding Final Answer Sheet

Total questions: 54

Worksheet time: 54mins

Name
Class
Date
1.
  1. What is a possible result of this code when it is run in a browser?

a)

I looked outside and the weather report is true

b)

I looked outside and the weather report is wrong

c)

I looked outside and the weather report is canceled

d)

I looked outside and the weather report is OK

2.
  1. What does the operator === mean?

a)

The operands on either side are equal in value but not necessarily in data type

b)

The operands on either side are equal in both value and data type

c)

The operands on either side are equal in either value and data type

d)

The value of the right operand is assigned to the left operand

3.
  1. What will the window alert box display when the script is run in the browser?

a)

An error will occur because you cannot perform a Boolean operation on a string

b)

It's before today

c)

It's after today

d)

It's before today/ It's after today

4.
  1. What is the result of clicking the button?

a)

The form will disable itself

b)

The button will become unresponsive

c)

The text field will become unresponsive

d)

Nothing will change

5.
  1. What will happen when the Confirm Box button is clicked?

a)

Regardless of a user action, the alert box that says "The box is checked" will display due to a coding error

b)

Regardless of a user action, the alert box that says "The box is not checked at the moment" will display due to a coding error

c)

Depending on a user action, one of the two alert boxes will display

d)

An error will return because the wrong form is identified in the if statement

6.
  1. In an AJAX transaction, which readyState value indicates that the HTTP response headers have been

    received from the server, but the message body has not yet been completely received from the client?

a)

value 2

b)

value 1

c)

value 0

d)

value 3

7.
  1. Which of the following practices will you use for preventing cross-site scripting (XSS) attacks?

a)

Avoiding the use of deprecated or unknown code

b)

Writing code consistently and with liberal comments

c)

Testing scripts thoroughly on various browsers

d)

Using output encoding and input validation practices

8.
  1. What output will be displayed in the alert box when the script is run in the browser?

a)

Sabrina, Kelly, Jill, Kris

b)

Kris, Sabrina, Kelly, Jill

c)

Kris, Kelly, Jill

d)

Sabrina, Kris, Jill

9.
  1. Which code is the JavaScript equivalent of clicking a browser’s Back button?

a)

history -= 1

b)

history.rewind();

c)

history.go(back);

d)

history.go(-1);

10.
  1. How would you find the position of the last letter “a” in the given code?

a)

.nurseryRhyme.lastIndexOf(“a”);

b)

charAt(nurseryRhyme, "a");

c)

nurseryRhyme.indexOf(“a”);

d)

indexOf(nurseryRhyme, “a”);

11.
  1. What is the value of myVar after execution?

a)

23

b)

2

c)

3

d)

5

12.
  1. In one JavaScript-related security vulnerability, an attacker embeds malicious script into a link that

    appears to be from a trusted site. Upon clicking the link, the embedded script is submitted in the

    client’s HTTP request and can execute on the user’s computer, enabling the attacker to steal

    information. What is the term for this security issue?

a)

Signed script

b)

Frame-to-frame URL changing

c)

Client-side browser detection

d)

Cross-site scripting

13.
  1. Choose the correct answer belowWhat will the alert box display when this script is run in the browser?

a)

Sabrina, Kelly, JillKris

b)

SabrinaKrisKellyKrisJill

c)

KrisKellyJill

d)

Kris, Sabrina, Kelly, Jill

14.
  1. You created a Webpage containing a form for users to join your company’s mailing list. You need to

    validate user input with the minimum amount of bandwidth. Which technology should you use in the

    given scenario?

a)

PHP

b)

Perl

c)

Server-side JavaScript

d)

Client-side JavaScript

15.
  1. What makes a scripting language different from a programming language?

a)

Scripting languages are based on Windows, while programming languages are based on UNIX.

b)

Scripting languages are based on UNIX, while programming languages are based on Windows.

c)

Scripting languages are interpreted while programming languages are compiled.

d)

Scripting languages are Web-based, while programming languages are not.

16.
  1. What is the term for a JavaScript function used to create a custom object?

a)

Initializer

b)

New

c)

Loader

d)

Constructor

17.
  1. Which of the following will select the third option in the list?

a)

b)

c)

d)

18.
  1. Which method will bring a window object to the top?

a)

window.blur()

b)

window.moveTo()

c)

C window.moveBy()

d)

window.focus()

19.
  1. Which JavaScript event handler is triggered when a user clicks her mouse button outside of a

    particular field after typing input there?

a)

onmouseout

b)

onblur

c)

onclick

d)

Onfocus

20.
  1. What is the output when the script is run in the browser?

a)

0+1+2+3+4+5+6+7+8+9+10+= 55

b)

0+1+2+3+4+5+6+7+8+9+= 45

c)

0+1+2+3+4+5+6+7+8+9+10 = 012345678910

d)

0+1+2+3+4+5+6+7+8+9 = 0123456789

21.
  1. Which event handler of the select object specifies the JavaScript code to execute when the select

    object loses focus after a user makes a selection, but only if the user selects an option other than the

    default?

a)

onclick

b)

onblur

c)

onchange

d)

onfocus

22.
  1. What is the expected result when this script is run in the browser?

a)

The background of the text box will change to blue.

b)

The background of the button will change to blue.

c)

The background of the page will change to blue.

d)

The background of the form will change to blue.

23.
  1. What will be the result of this script when run in a browser?

a)

Hello World

b)

An error, because the variables are not properly declared

c)

An error, because concatenation requires the & operator

d)

Hello

24.
  1. Which statement about the protype property is true?

a)

It is only available in DOM objects.

b)

It is only available in custom objects.

c)

It is only available in JavaScript predefined objects.

d)

It is available in every JavaScript object

25.
  1. Which code snippet can be used to display the current date?

a)

b)

c)

d)

26.
  1. What is the purpose of the break statement in JavaScript?

a)
  1. To destroy unused variables

b)
  1. To terminate the current iteration and jump over the next iteration of the loop

c)
  1. To flush system memory

d)
  1. To exit a control structure

27.
  1. Which of the following is a tool that is used to help find errors in JavaScript code?

a)
  1. Compiler

b)
  1. Script library

c)
  1. Interpreter

d)
  1. Debugger

28.
  1. Which example demonstrates the correct syntax for declaring a variable?

a)
  1. var @lastName;

b)
  1. var 2lasstName;

c)
  1. var .last_name;

d)
  1. var _LAST_name

29.
  1. What does Y represent in this statement?

a)

The condition under which the loop will execute

b)

The loop counter increment or decrement

c)

The highest value that the counter variable may reach

d)

The loop counter variable initialization expression

30.
  1. Which of the following is a typical AJAX request?

a)

Returning server variables from a server to a client

b)

Converting XML data to CSS data

c)

Informing the server of client configurations

d)

Uploading variables from a client database to a server

31.
  1. Assume that you input the numbers 8 and 9 when the script is run in the browser. What is the possible

    result of this script?

a)

The sum of two numbers is undefined.

b)

The sum of the two numbers is 8

c)

The sum of the two numbers is 17.

d)

The sum of the two numbers is 89

32.
  1. Which type of error are you most likely to debug using watchpoints?

a)
  1. Run-time

b)
  1. Syntax

c)
  1. Logic

d)
  1. Load-time

33.
  1. Which browser security consideration should a JavaScript developer remember when developing a

    script?

a)
  1. JavaScript functionality is immune to viruses, trojans, and malware.

b)
  1. JavaScript can be disabled by a user and therefore cannot be relied upon to run.

c)
  1. JavaScript is a cross-platform scripting language and will generate consistent results regardless

    of the client or server being used.

d)
  1. Certain JavaScript functionality is built into browsers and has been tested by the browser

    developers so it cannot be disabled by a user because it is deemed safe.

34.
  1. Cross-site scripting (XSS) is a type of:

a)
  1. Same origin policy violation.

b)
  1. Security risk associated with signed scripts.

c)
  1. Phishing scam.

d)
  1. Code-injection attack

35.
  1. In an AJAX transaction, which readyState value indicates that the XMLHttpRequest has been sent but

    no response has been received yet?

a)

value 1

b)

value 2

c)

value 3

d)

value 4

36.
  1. Which of the following will you add to the regular expression that allows the matching of the letters

    in postal codes?

a)

\s

b)

\W

c)

\w

d)

\s

37.
  1. Which JavaScript object reflects information about the browser being used to view the Webpage?

a)
  1. Window

b)
  1. Navigator

c)
  1. Location

d)

D. document

38.
  1. Which of the following will correctly retrieve the corresponding value of an HTML element’s

    attribute within the DOM?

a)
  1. getAttribute(AttributeName)

b)
  1. setAttribute(AttributeName

c)
  1. setAttribute(AttributeName, NewValue)

d)
  1. getAttribute(AttributeName, NewValue)

39.
  1. What will be the output of the given code block?

a)

My pet is a Frog

b)

My pet is a Rabbit

c)

I do not have a pet

d)

I have a Rabbit and a Frog

40.
  1. What was Server-Side JavaScript (SSJS) originally called?

a)

Perl

b)

AJAX

c)

JScript

d)

LiveWire

41.
  1. Which of the following is a disadvantage of using the JavaSvript library?

a)
  1. Each library is browser-specific, thus the code provided will be browser-specific.

b)
  1. Using a JavaScript library does not guarantee high-quality, , secure code.

c)
  1. Libraries are not available to the public; you must either work for a company that provides one

    or purchase a membership

d)
  1. Developing Progressive Web Applications with enhanced UI using JavaScript libraries will be a

    complex task.

42.
  1. Which of the following is a disadvantage of using the JavaScript library?

a)

Each library is browser-specific, thus the code provided will be browser-specific.

b)

Using a JavaScript library does not guarantee high-quality, secure code.

c)

Libraries are not available to the public; you must either work for a company that provides one

or purchase a membership.

d)

Developing Progressive Web Applications with enhanced UI using JavaScript libraries will be a

complex task.

43.
  1. Which of the following is true about the do-while statement?

a)
  1. It executes only if the condition is true.

b)
  1. It always executes at least once regardless of the conditi

c)
  1. It can take an optional condition as an argument.

d)
  1. It tests a condition prior to running a block of code.

44.
  1. What is the expected result when this script is run in the browser?

a)
  1. The window alert box will not appear because there is an error in the code

b)
  1. The window alert box will display Good, then the user clicks the OK button it will display Bad.

c)
  1. The window alert box will display Bad.

d)
  1. The window alert box will display Good

45.
  1. Which data type is a variable that has no value assigned to it yet?

a)
  1. undefined

b)
  1. null

c)
  1. string

d)
  1. boolean

46.
  1. What is the value of myVar after the execution of this script?

a)

35

b)

2

c)

3

d)

5

47.
  1. Which JavaScript “flavor” attempts to diminish the differences between other JavaScript flavors and

    standardize the language?

a)
  1. VBScript

b)
  1. JavaScript

c)
  1. ECMAScript

d)
  1. JScript

48.
  1. You work for a mid-size company with a large Website that has a very wide customer base. Which is

    the best method for testing your JavaScript code for this site?

a)
  1. Determine the most frequently used browsers for your target audience, and test in those

    browsers.

b)
  1. Test in various versions of the most popular browser.

c)
  1. Test in various browsers, versions and operating systems.

d)
  1. Test in various browsers, including various versions of the same browser.

49.
  1. What will the alert box display when this script is run in a browser?

a)
  1. Thursday

b)
  1. ThursdayWednesday

c)
  1. Wednesday

d)
  1. WednesdayThursday

50.
  1. What are cookies?

a)
  1. Small pieces of information sent to a client computer

b)
  1. Malicious JavaScript code

c)
  1. Compiled Java code with which JavaScript can interac

d)
  1. Small JavaScript applications

51.
  1. Which of the following methods could be used to change the value of the first radio button?

a)
  1. document.myForm.rdoGroup1[0].value = “Green”

b)
  1. document.getElementByld(rdoGroup1).value = “Green”

c)
  1. document.getElementByld(“rdoGroup1”).value = “Green”

d)
  1. document.rdoGroup1.value = “Green”

52.
  1. Which of the following is not a valid variable name in JavaScript?

a)
  1. _this

b)
  1. that

c)
  1. this

d)
  1. _that

53.
  1. Your site has a Webpage that uses AJAX to refresh a portion of the content based on the user’s

    action. A user has made a selection on this page and is waiting for a response. While waiting, she

    changes her mind and makes a different selection before receiving a response to her first selection. She

    is confused when the eventual response does not seem to match her second action. This example

    shows what type of disadvantage of using AJAX on a Webpage?

a)
  1. Server response issue

b)
  1. Script blocking issue

c)
  1. Usability issue

d)
  1. Security issue

54.
  1. What will the alert box display when this script is run in the browser?

a)
  1. SabrinaKellyJill

b)
  1. Sabrina, Kelly,

c)
  1. Sabrina

d)
  1. Jill