Ensurepass

QUESTION 41

Consider the following code: var myString= "Hello World"; alert(myString.length);

What is the output when you run this script in the browser?

A.An alert box displaying the following: "Hello World", 11

B.An alert box displaying the following: myString, 11

C.An alert box displaying the following: Hello World

D.An alert box displaying the following: 11

 

Answer: D

 

 

QUESTION 42

Consider the following code:

clip_image001

What needs to be changed to allow this script to run without error?

A.Change the substring method call to substr

B.Change the substring method call to substr()

C.Change the characterAt method call to charAt

D.Change the characterAt method call to characterat

 

Answer: C

 

 

QUESTION 43

Which of the following is a reason why a developer would use a JavaScript library?

A.JavaScript libraries ensure quality code that does not harbor security risks.

B.JavaScript libraries require a shorter learning curve than JavaScript.

C.JavaScript libraries are subsets of Java and thus provide more powerful code.

D.JavaScript libraries provide platform-independent code that will behave identically in any browser.

 

Answer: B

 

 

QUESTION 44

Which of the following will correctly declare the EmployeeID variable as a string data type?

A.string EmployeeID = 123;

B.string EmployeeID = "123";

C.var EmployeeID = 123;

D.var EmployeeID = "123";

 

Answer: D

 

 

QUESTION 45

Which of the following will correctly modify the value of an X/HTML element’s attribute within the DOM?

A.getAttribute(NewValue, AttributeName)

B.getAttribute(AttributeName, NewValue)

C.setAttribute(NewValue, AttributeName)

D.setAttribute(AttributeName, NewValue)

 

Answer: D

 

 

QUESTION 46

Consider the following select list:

clip_image002

Which of the following will select the third option in the list?

A.var list = document.getElementById("numlist"); list.selected = 3;

B.var list = document.getElementById("numlist"); list.options[2].selectedIndex();

C.var list = document.getElementById("numlist"); list.options.selectedIndex = 2;

D.var list = document.getElementById("numlist"); list[3].selected(true);

 

Answer: C

 

 

QUESTION 47

How is the alert() method different from prompt() and confirm()?

A.The alert() method generates a modal dialog box, which requires user action before the next JavaScript instruction can be executed,whereas prompt() and confirm() do not.

B.The alert() method requires only one parameter, whereas prompt() and confirm() require two parameters.

C.The alert() method requires two parameters, whereas prompt() and confirm() require only one parameter.

D.The prompt() and confirm() methods return a value, whereas alert() does not.

 

Answer: D

 

 

QUESTION 48

Maria, a 22-year old student, is testing her JavaScript application, which includes the following code:

clip_image003

Assuming Maria enters truthful information, what is the value of z after executing this code?

A.No value ?error in line 1 due to missing var keyword for userAge.

B.No value ?error in line 1 due to multiple declarations in one line.

C.Maria "is" 22 "years old"

D.Maria is 22 years old

 

Answer: D

 

 

QUESTION 49

Consider the following code:

clip_image004

When a user clicks on the displayed link, which site will he navigate to?

A.www.msn.com

B.www.yahoo.com

C.www.google.com

D.No other site, because there is a runtime error

 

Answer: B

 

 

QUESTION 50

Consider the following code using a checkbox object:

clip_image005

Which checkbox property was used by JavaScript?

A.checked

B.onclick()

C.checkThis

D.z-index

 

Answer: A

 

 

Comments are closed.