1. Which of the following statements would correctly print out the sentence “Hel
ID: 3795020 • Letter: 1
Question
1. Which of the following statements would correctly print out the sentence “Hello World” in blue? a) document.write( “<p style = ”color: blue”); document.write( “Hello World >”); b) document.write( “<p> style = ”color: blue” Hello World </p>); c) document.write( “<p style = ”color: blue” Hello World + “</p>”); d) document.write( “<p style = ”color: blue”>”); document.write( “Hello World </p>”); 2. An alert dialog displaying the text “Welcome!” is created by calling _________. a) window.alert( “Welcome!” ); b) alert.window( “Welcome!” ); c) window( “alert = ”Welcome!”” ); d) window( “<alert> Welcome! </alert>” ); 3. Consider the following script. What is wrong with the following code? <script type = “text/javascript”> var firstNumber; thirdNumber; firstNumber = window.prompt(“Enter an integer”, “0”); secondNumber = window.prompt(“Enter an integer”, “0”); thirdNumber = firstNumber + secondNumber; </script> a) thirdNumber in line 7 must be in quotes. b) The words Enter an integer in line 6 should not be in quotes. c) The word thirdnumber in line 3 should have a comma after it. d) The word var must be placed before thirdNumber in line 3. 4. Which of the following is not a valid variable name? a) Tax1 b) eightball_8 c) 12footage d) pageNumber1200 5. What will the browser display if the following script is executed and the user enters 5 at both prompts? <script type = “text/javascript”> <!-- var firstNumber = window.prompt( “Enter an integer”, “0” ); var secondNumber= window.prompt( “Enter an integer”, “0” ); var thirdNumber; thirdNumber = firstNumber + secondNumber; document.write( thirdNumber ); //--> </script> a) nothing b) 0 c) 10 d) 55 6.. What is the result of the statement 17 % 5? a) 0 b) 2 c) 3 d) 12 7. What does the following expression evaluate to? ( ( 3 + ( 5 + 4 ) * 7 ) + 4 ) / 5 a) 8 b) 14 c) 17.6 d) 26.4 8. Which of the following statements is correctly written? a) If ( studentGrade >= 60 ) document.writeln( "Passed" ); b) if ( studentGrade >= 60 ); document.writeln( "Passed" ); c) if ( studentGrade >= 60 ) document.write( "Passed" ); d) If ( studentGrade >= 60 ); document.write( "Passed" ); 9. What would the browser display if the following code were executed in a script? var x = 11; var y = 14; if ( x > 13 ) if ( y > 13 ) document.writeln( "x and y are > 13" ); else document.writeln( "x is <= 13" ); a) nothing b) 11 c) x and y are > 13 d) x is <= 13 10. What is displayed by the following javascript snippet. var grade = 59; if ( grade >= 60 ) document.writeln( "Passed." ); else document.write( "Failed. " ); document.writeln( "You must take this course again." ); a) Passed. b) Failed. c) You must take this course again. d) Failed. You must take this course again. 11. What would the browser display if the following code were executed in a script? var product = 0;while ( product <= 25 ); product = 2 + product; a) nothing, the script would result in an error b) 0 c) 25 d) 26 12. What would the browser display if the following code were executed in a script? var product = 0; while (product >= 25) product = 2 + product; document.writeln( product ); a) nothing, the script would result in an error b) 0 c) 24 d) 26 13. What would the browser display if the following script were executed? <script type = "text/javascript"> var count = 0; var total = 0; while ( count <= 5 ) { total = total + 10; count = count + 1; } document.write( total ); </script> a) Nothing; the browser would generate an error. b) 0 c) 50 d) 60 14. What would the browser display if the following script were executed? <script type = "text/javascript"> var count = 5; var total = 0; while ( count > -1 ) { total = total - 10; count = count - 1; } document.write( total ); </script> a) Nothing; the browser would generate an error. b) 0 c) -50 d) -60 15. If the string passed to parseInt contains a floating-point numeric value, parseInt will ________. a) return NaN b) return 0 c) round the value to the nearest tenth d) truncate the floating-point part to be left with an integer value 16. If the string passed to parseInt contains text characters, parseInt will ________. a) return NaN b) return 0 c) return the sum of the characters' ASCII values d) truncate the text entries 17. What output will the following script produce? var i = 0; var j = 3; var counter = 0; while ( i < 5 ) { if (i != j) counter = counter + i; i = i + 1 } document.write( counter ); a) 9 b) 14 c) 3 d) 7 18. Which of the following is the proper method to access the length of the array arr? a) arr[].length b) arr[subscript].length c) arr.length d) arr(length) 19. To divide the value of the seventh element of array a by 2 and assign the result to the variable x, we would write ________. a) x / 2 = a( 7 ) b) x = a[ 7 ] / 2 c) x = a[ 6 ] / 2 d) x = a( 6 / 2 ) 20. Which of the following is the proper method to dynamically allocate memory to an array of 100 elements? a) var c = new c[ 100 ]; b) var c = new c( 100 ); c) var c = new Array[ 100 ]; d) var c = new Array( 100 ); 21. The first statement below ________ the array while the second statement ________ the array. var c; c = new Array( 12 ); a) declares, initializes b) initializes, declares c) declares, allocates d) allocates, declares 22. Which of the following is an illegal array initialization statement? a) var n = [ 10, 20, 30, 40, 50 ]; b) var n = new Array( 10, 20, 30, 40, 50 ); c) var n[ 10, 20, 30, 40, 50 ]; d) var n = new Array( 5 ); for ( var i = 1; i <= 5; i++ ) n[ i ] = i * 10 ; 23. What is the value of num assuming that all 12 elements of array test are initialized to 3? ++test[ 7 ]; var num = test[ 7 ]; a) 3 b) 4 c) 8 d) 10 24. What will the browser display if the following script is executed? <script type = "text/javascript"> <!-- var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; modifyArray( theArray[ 3 ] ); document.write( theArray.join( " " ) ); function modifyArray( i ) { i = 11; } //--> </script> a) Nothing, the browser will generate an error. b) 1 2 3 4 5 6 7 8 9 c) 1 2 11 4 5 6 7 8 9 d) 1 2 3 11 5 6 7 8 9 25. What does the variable string contain after the following code is executed? var string = "Good luck on the test"; string = string.charAt( 3 ); a) Goo b) 3 c) d d) Nothing, the string conversion generates an error. 26. What does the variable string contain after the following code is executed? var string = "Good luck on the test"; string = string.split( " " ); a) an array containing the strings "Good", "luck", "on", "the" and "test" b) the string "Good.luck.on.the.test" c) the string "Good,luck,on,the,test" d) Nothing, the string conversion will generate an error. 27. What is the value of s3 after the following code is executed? var s1 = “one”; var s2 = “two”; var s3 = “three”; s1.concat( s2 ); s3 = s1; a) one b) onetwo c) three d) onetwothree 28. Which of the following methods would you use to search a string for a specific character? a) substring b) charAt c) substr d) indexOf 29. The window object includes the method _____ for creating new browser windows. a) new b) open c) create d) spawn 30. Method _____ of the window object provides a way to ask users for input. a) close b) response c) ask d) prompt 1. Which of the following statements would correctly print out the sentence “Hello World” in blue? a) document.write( “<p style = ”color: blue”); document.write( “Hello World >”); b) document.write( “<p> style = ”color: blue” Hello World </p>); c) document.write( “<p style = ”color: blue” Hello World + “</p>”); d) document.write( “<p style = ”color: blue”>”); document.write( “Hello World </p>”); 2. An alert dialog displaying the text “Welcome!” is created by calling _________. a) window.alert( “Welcome!” ); b) alert.window( “Welcome!” ); c) window( “alert = ”Welcome!”” ); d) window( “<alert> Welcome! </alert>” ); 3. Consider the following script. What is wrong with the following code? <script type = “text/javascript”> var firstNumber; thirdNumber; firstNumber = window.prompt(“Enter an integer”, “0”); secondNumber = window.prompt(“Enter an integer”, “0”); thirdNumber = firstNumber + secondNumber; </script> a) thirdNumber in line 7 must be in quotes. b) The words Enter an integer in line 6 should not be in quotes. c) The word thirdnumber in line 3 should have a comma after it. d) The word var must be placed before thirdNumber in line 3. 4. Which of the following is not a valid variable name? a) Tax1 b) eightball_8 c) 12footage d) pageNumber1200 5. What will the browser display if the following script is executed and the user enters 5 at both prompts? <script type = “text/javascript”> <!-- var firstNumber = window.prompt( “Enter an integer”, “0” ); var secondNumber= window.prompt( “Enter an integer”, “0” ); var thirdNumber; thirdNumber = firstNumber + secondNumber; document.write( thirdNumber ); //--> </script> a) nothing b) 0 c) 10 d) 55 6.. What is the result of the statement 17 % 5? a) 0 b) 2 c) 3 d) 12 7. What does the following expression evaluate to? ( ( 3 + ( 5 + 4 ) * 7 ) + 4 ) / 5 a) 8 b) 14 c) 17.6 d) 26.4 8. Which of the following statements is correctly written? a) If ( studentGrade >= 60 ) document.writeln( "Passed" ); b) if ( studentGrade >= 60 ); document.writeln( "Passed" ); c) if ( studentGrade >= 60 ) document.write( "Passed" ); d) If ( studentGrade >= 60 ); document.write( "Passed" ); 9. What would the browser display if the following code were executed in a script? var x = 11; var y = 14; if ( x > 13 ) if ( y > 13 ) document.writeln( "x and y are > 13" ); else document.writeln( "x is <= 13" ); a) nothing b) 11 c) x and y are > 13 d) x is <= 13 10. What is displayed by the following javascript snippet. var grade = 59; if ( grade >= 60 ) document.writeln( "Passed." ); else document.write( "Failed. " ); document.writeln( "You must take this course again." ); a) Passed. b) Failed. c) You must take this course again. d) Failed. You must take this course again. 11. What would the browser display if the following code were executed in a script? var product = 0;
while ( product <= 25 ); product = 2 + product; a) nothing, the script would result in an error b) 0 c) 25 d) 26 12. What would the browser display if the following code were executed in a script? var product = 0; while (product >= 25) product = 2 + product; document.writeln( product ); a) nothing, the script would result in an error b) 0 c) 24 d) 26 13. What would the browser display if the following script were executed? <script type = "text/javascript"> var count = 0; var total = 0; while ( count <= 5 ) { total = total + 10; count = count + 1; } document.write( total ); </script> a) Nothing; the browser would generate an error. b) 0 c) 50 d) 60 14. What would the browser display if the following script were executed? <script type = "text/javascript"> var count = 5; var total = 0; while ( count > -1 ) { total = total - 10; count = count - 1; } document.write( total ); </script> a) Nothing; the browser would generate an error. b) 0 c) -50 d) -60 15. If the string passed to parseInt contains a floating-point numeric value, parseInt will ________. a) return NaN b) return 0 c) round the value to the nearest tenth d) truncate the floating-point part to be left with an integer value 16. If the string passed to parseInt contains text characters, parseInt will ________. a) return NaN b) return 0 c) return the sum of the characters' ASCII values d) truncate the text entries 17. What output will the following script produce? var i = 0; var j = 3; var counter = 0; while ( i < 5 ) { if (i != j) counter = counter + i; i = i + 1 } document.write( counter ); a) 9 b) 14 c) 3 d) 7 18. Which of the following is the proper method to access the length of the array arr? a) arr[].length b) arr[subscript].length c) arr.length d) arr(length) 19. To divide the value of the seventh element of array a by 2 and assign the result to the variable x, we would write ________. a) x / 2 = a( 7 ) b) x = a[ 7 ] / 2 c) x = a[ 6 ] / 2 d) x = a( 6 / 2 ) 20. Which of the following is the proper method to dynamically allocate memory to an array of 100 elements? a) var c = new c[ 100 ]; b) var c = new c( 100 ); c) var c = new Array[ 100 ]; d) var c = new Array( 100 ); 21. The first statement below ________ the array while the second statement ________ the array. var c; c = new Array( 12 ); a) declares, initializes b) initializes, declares c) declares, allocates d) allocates, declares 22. Which of the following is an illegal array initialization statement? a) var n = [ 10, 20, 30, 40, 50 ]; b) var n = new Array( 10, 20, 30, 40, 50 ); c) var n[ 10, 20, 30, 40, 50 ]; d) var n = new Array( 5 ); for ( var i = 1; i <= 5; i++ ) n[ i ] = i * 10 ; 23. What is the value of num assuming that all 12 elements of array test are initialized to 3? ++test[ 7 ]; var num = test[ 7 ]; a) 3 b) 4 c) 8 d) 10 24. What will the browser display if the following script is executed? <script type = "text/javascript"> <!-- var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; modifyArray( theArray[ 3 ] ); document.write( theArray.join( " " ) ); function modifyArray( i ) { i = 11; } //--> </script> a) Nothing, the browser will generate an error. b) 1 2 3 4 5 6 7 8 9 c) 1 2 11 4 5 6 7 8 9 d) 1 2 3 11 5 6 7 8 9 25. What does the variable string contain after the following code is executed? var string = "Good luck on the test"; string = string.charAt( 3 ); a) Goo b) 3 c) d d) Nothing, the string conversion generates an error. 26. What does the variable string contain after the following code is executed? var string = "Good luck on the test"; string = string.split( " " ); a) an array containing the strings "Good", "luck", "on", "the" and "test" b) the string "Good.luck.on.the.test" c) the string "Good,luck,on,the,test" d) Nothing, the string conversion will generate an error. 27. What is the value of s3 after the following code is executed? var s1 = “one”; var s2 = “two”; var s3 = “three”; s1.concat( s2 ); s3 = s1; a) one b) onetwo c) three d) onetwothree 28. Which of the following methods would you use to search a string for a specific character? a) substring b) charAt c) substr d) indexOf 29. The window object includes the method _____ for creating new browser windows. a) new b) open c) create d) spawn 30. Method _____ of the window object provides a way to ask users for input. a) close b) response c) ask d) prompt 1. Which of the following statements would correctly print out the sentence “Hello World” in blue? a) document.write( “<p style = ”color: blue”); document.write( “Hello World >”); b) document.write( “<p> style = ”color: blue” Hello World </p>); c) document.write( “<p style = ”color: blue” Hello World + “</p>”); d) document.write( “<p style = ”color: blue”>”); document.write( “Hello World </p>”); 2. An alert dialog displaying the text “Welcome!” is created by calling _________. a) window.alert( “Welcome!” ); b) alert.window( “Welcome!” ); c) window( “alert = ”Welcome!”” ); d) window( “<alert> Welcome! </alert>” ); 3. Consider the following script. What is wrong with the following code? <script type = “text/javascript”> var firstNumber; thirdNumber; firstNumber = window.prompt(“Enter an integer”, “0”); secondNumber = window.prompt(“Enter an integer”, “0”); thirdNumber = firstNumber + secondNumber; </script> a) thirdNumber in line 7 must be in quotes. b) The words Enter an integer in line 6 should not be in quotes. c) The word thirdnumber in line 3 should have a comma after it. d) The word var must be placed before thirdNumber in line 3. 4. Which of the following is not a valid variable name? a) Tax1 b) eightball_8 c) 12footage d) pageNumber1200 5. What will the browser display if the following script is executed and the user enters 5 at both prompts? <script type = “text/javascript”> <!-- var firstNumber = window.prompt( “Enter an integer”, “0” ); var secondNumber= window.prompt( “Enter an integer”, “0” ); var thirdNumber; thirdNumber = firstNumber + secondNumber; document.write( thirdNumber ); //--> </script> a) nothing b) 0 c) 10 d) 55 6.. What is the result of the statement 17 % 5? a) 0 b) 2 c) 3 d) 12 7. What does the following expression evaluate to? ( ( 3 + ( 5 + 4 ) * 7 ) + 4 ) / 5 a) 8 b) 14 c) 17.6 d) 26.4 8. Which of the following statements is correctly written? a) If ( studentGrade >= 60 ) document.writeln( "Passed" ); b) if ( studentGrade >= 60 ); document.writeln( "Passed" ); c) if ( studentGrade >= 60 ) document.write( "Passed" ); d) If ( studentGrade >= 60 ); document.write( "Passed" ); 9. What would the browser display if the following code were executed in a script? var x = 11; var y = 14; if ( x > 13 ) if ( y > 13 ) document.writeln( "x and y are > 13" ); else document.writeln( "x is <= 13" ); a) nothing b) 11 c) x and y are > 13 d) x is <= 13 10. What is displayed by the following javascript snippet. var grade = 59; if ( grade >= 60 ) document.writeln( "Passed." ); else document.write( "Failed. " ); document.writeln( "You must take this course again." ); a) Passed. b) Failed. c) You must take this course again. d) Failed. You must take this course again. 11. What would the browser display if the following code were executed in a script? var product = 0;
while ( product <= 25 ); product = 2 + product; a) nothing, the script would result in an error b) 0 c) 25 d) 26 12. What would the browser display if the following code were executed in a script? var product = 0; while (product >= 25) product = 2 + product; document.writeln( product ); a) nothing, the script would result in an error b) 0 c) 24 d) 26 13. What would the browser display if the following script were executed? <script type = "text/javascript"> var count = 0; var total = 0; while ( count <= 5 ) { total = total + 10; count = count + 1; } document.write( total ); </script> a) Nothing; the browser would generate an error. b) 0 c) 50 d) 60 14. What would the browser display if the following script were executed? <script type = "text/javascript"> var count = 5; var total = 0; while ( count > -1 ) { total = total - 10; count = count - 1; } document.write( total ); </script> a) Nothing; the browser would generate an error. b) 0 c) -50 d) -60 15. If the string passed to parseInt contains a floating-point numeric value, parseInt will ________. a) return NaN b) return 0 c) round the value to the nearest tenth d) truncate the floating-point part to be left with an integer value 16. If the string passed to parseInt contains text characters, parseInt will ________. a) return NaN b) return 0 c) return the sum of the characters' ASCII values d) truncate the text entries 17. What output will the following script produce? var i = 0; var j = 3; var counter = 0; while ( i < 5 ) { if (i != j) counter = counter + i; i = i + 1 } document.write( counter ); a) 9 b) 14 c) 3 d) 7 18. Which of the following is the proper method to access the length of the array arr? a) arr[].length b) arr[subscript].length c) arr.length d) arr(length) 19. To divide the value of the seventh element of array a by 2 and assign the result to the variable x, we would write ________. a) x / 2 = a( 7 ) b) x = a[ 7 ] / 2 c) x = a[ 6 ] / 2 d) x = a( 6 / 2 ) 20. Which of the following is the proper method to dynamically allocate memory to an array of 100 elements? a) var c = new c[ 100 ]; b) var c = new c( 100 ); c) var c = new Array[ 100 ]; d) var c = new Array( 100 ); 21. The first statement below ________ the array while the second statement ________ the array. var c; c = new Array( 12 ); a) declares, initializes b) initializes, declares c) declares, allocates d) allocates, declares 22. Which of the following is an illegal array initialization statement? a) var n = [ 10, 20, 30, 40, 50 ]; b) var n = new Array( 10, 20, 30, 40, 50 ); c) var n[ 10, 20, 30, 40, 50 ]; d) var n = new Array( 5 ); for ( var i = 1; i <= 5; i++ ) n[ i ] = i * 10 ; 23. What is the value of num assuming that all 12 elements of array test are initialized to 3? ++test[ 7 ]; var num = test[ 7 ]; a) 3 b) 4 c) 8 d) 10 24. What will the browser display if the following script is executed? <script type = "text/javascript"> <!-- var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; modifyArray( theArray[ 3 ] ); document.write( theArray.join( " " ) ); function modifyArray( i ) { i = 11; } //--> </script> a) Nothing, the browser will generate an error. b) 1 2 3 4 5 6 7 8 9 c) 1 2 11 4 5 6 7 8 9 d) 1 2 3 11 5 6 7 8 9 25. What does the variable string contain after the following code is executed? var string = "Good luck on the test"; string = string.charAt( 3 ); a) Goo b) 3 c) d d) Nothing, the string conversion generates an error. 26. What does the variable string contain after the following code is executed? var string = "Good luck on the test"; string = string.split( " " ); a) an array containing the strings "Good", "luck", "on", "the" and "test" b) the string "Good.luck.on.the.test" c) the string "Good,luck,on,the,test" d) Nothing, the string conversion will generate an error. 27. What is the value of s3 after the following code is executed? var s1 = “one”; var s2 = “two”; var s3 = “three”; s1.concat( s2 ); s3 = s1; a) one b) onetwo c) three d) onetwothree 28. Which of the following methods would you use to search a string for a specific character? a) substring b) charAt c) substr d) indexOf 29. The window object includes the method _____ for creating new browser windows. a) new b) open c) create d) spawn 30. Method _____ of the window object provides a way to ask users for input. a) close b) response c) ask d) prompt
Explanation / Answer
1. Which of the following statements would correctly print out the sentence “Hello World” in blue?
a) document.write( “<p style = ”color: blue”);
document.write( “Hello World >”);
b) document.write( “<p> style = ”color: blue” Hello World </p>);
c) document.write( “<p style = ”color: blue” Hello World + “</p>”);
d) document.write( “<p style = ”color: blue”>”);
document.write( “Hello World </p>”);
ans)option D is correct
2. An alert dialog displaying the text “Welcome!” is created by calling _________.
a) window.alert( “Welcome!” );
b) alert.window( “Welcome!” );
c) window( “alert = ”Welcome!”” );
d) window( “<alert> Welcome! </alert>” );
ans)option A correct
3. Consider the following script. What is wrong with the following code?
<script type = “text/javascript”>
var firstNumber;
thirdNumber;
firstNumber = window.prompt(“Enter an integer”, “0”);
secondNumber = window.prompt(“Enter an integer”, “0”);
thirdNumber = firstNumber + secondNumber;
</script>
a) thirdNumber in line 7 must be in quotes.
b) The words Enter an integer in line 6 should not be in quotes.
c) The word thirdnumber in line 3 should have a comma after it.
d) The word var must be placed before thirdNumber in line 3.
ans)option D is correct
4. Which of the following is not a valid variable name?
a) Tax1
b) eightball_8
c) 12footage
d) pageNumber1200
ans) option C correct
5. What will the browser display if the following script is executed and the user enters 5 at both prompts?
<script type = “text/javascript”>
<!--
var firstNumber = window.prompt( “Enter an integer”, “0” );
var secondNumber= window.prompt( “Enter an integer”, “0” );
var thirdNumber;
thirdNumber = firstNumber + secondNumber;
document.write( thirdNumber );
//-->
</script>
a) nothing
b) 0
c) 10
d) 55
ans)option A correct
6.. What is the result of the statement 17 % 5?
a) 0
b) 2
c) 3
d) 12
ans)option B correct
7. What does the following expression evaluate to?
( ( 3 + ( 5 + 4 ) * 7 ) + 4 ) / 5
a) 8
b) 14
c) 17.6
d) 26.4
ans)option B correct
8. Which of the following statements is correctly written?
a) If ( studentGrade >= 60 )
document.writeln( "Passed" );
b) if ( studentGrade >= 60 );
document.writeln( "Passed" );
c) if ( studentGrade >= 60 )
document.write( "Passed" );
d) If ( studentGrade >= 60 );
document.write( "Passed" );
ans) option C correct
9. What would the browser display if the following code were executed in a script?
var x = 11;
var y = 14;
if ( x > 13 )
if ( y > 13 )
document.writeln( "x and y are > 13" );
else
document.writeln( "x is <= 13" );
a) nothing
b) 11
c) x and y are > 13
d) x is <= 13
ans)option A is correct
10. What is displayed by the following javascript snippet.
var grade = 59;
if ( grade >= 60 )
document.writeln( "Passed." );
else
document.write( "Failed. " );
document.writeln( "You must take this course again." );
a) Passed.
b) Failed.
c) You must take this course again.
d) Failed. You must take this course again.
ans)option D correct
11. What would the browser display if the following code were executed in a script?
var product = 0;
while ( product <= 25 );
product = 2 + product;
a) nothing, the script would result in an error
b) 0
c) 25
d) 26
ans)option A was correct
12. What would the browser display if the following code were executed in a script?
var product = 0;
while (product >= 25)
product = 2 + product;
document.writeln( product );
a) nothing, the script would result in an error
b) 0
c) 24
d) 26
ans)option B correct
13. What would the browser display if the following script were executed?
<script type = "text/javascript">
var count = 0;
var total = 0;
while ( count <= 5 )
{
total = total + 10;
count = count + 1;
}
document.write( total );
</script>
a) Nothing; the browser would generate an error.
b) 0
c) 50
d) 60
ans)option D correct
14. What would the browser display if the following script were executed?
<script type = "text/javascript">
var count = 5;
var total = 0;
while ( count > -1 )
{
total = total - 10;
count = count - 1;
}
document.write( total );
</script>
a) Nothing; the browser would generate an error.
b) 0
c) -50
d) -60
ans)option D correct
15. If the string passed to parseInt contains a floating-point numeric value, parseInt will ________.
a) return NaN
b) return 0
c) round the value to the nearest tenth
d) truncate the floating-point part to be left with an integer value
ans)option D correct
16. If the string passed to parseInt contains text characters, parseInt will ________.
a) return NaN
b) return 0
c) return the sum of the characters' ASCII values
d) truncate the text entries
ans)option A correct
17. What output will the following script produce?
var i = 0;
var j = 3;
var counter = 0;
while ( i < 5 )
{
if (i != j)
counter = counter + i;
i = i + 1
}
document.write( counter );
a) 9
b) 14
c) 3
d) 7
ans)option D correct
18. Which of the following is the proper method to access the length of the array arr?
a) arr[].length
b) arr[subscript].length
c) arr.length
d) arr(length)
ans)option C correct
19. To divide the value of the seventh element of array a by 2 and assign the result to the variable x, we would write ________.
a) x / 2 = a( 7 )
b) x = a[ 7 ] / 2
c) x = a[ 6 ] / 2
d) x = a( 6 / 2 )
ans)option C correct
20. Which of the following is the proper method to dynamically allocate memory to an array of 100 elements?
a) var c = new c[ 100 ];
b) var c = new c( 100 );
c) var c = new Array[ 100 ];
d) var c = new Array( 100 );
ans)option D correct
21. The first statement below ________ the array while the second statement ________ the array.
var c;
c = new Array( 12 );
a) declares, initializes
b) initializes, declares
c) declares, allocates
d) allocates, declares
ans)option C correct
22. Which of the following is an illegal array initialization statement?
a) var n = [ 10, 20, 30, 40, 50 ];
b) var n = new Array( 10, 20, 30, 40, 50 );
c) var n[ 10, 20, 30, 40, 50 ];
d) var n = new Array( 5 );
for ( var i = 1; i <= 5; i++ )
n[ i ] = i * 10 ;
ans)option C correct
23. What is the value of num assuming that all 12 elements of array test are initialized to 3?
++test[ 7 ];
var num = test[ 7 ];
a) 3
b) 4
c) 8
d) 10
ans)option B correct
24. What will the browser display if the following script is executed?
<script type = "text/javascript">
<!--
var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
modifyArray( theArray[ 3 ] );
document.write( theArray.join( " " ) );
function modifyArray( i )
{
i = 11;
}
//-->
</script>
a) Nothing, the browser will generate an error.
b) 1 2 3 4 5 6 7 8 9
c) 1 2 11 4 5 6 7 8 9
d) 1 2 3 11 5 6 7 8 9
ans)option B correct but the browser does not show anything in comments
25. What does the variable string contain after the following code is executed?
var string = "Good luck on the test";
string = string.charAt( 3 );
a) Goo
b) 3
c) d
d) Nothing, the string conversion generates an error.
ans)option C correct
26. What does the variable string contain after the following code is executed?
var string = "Good luck on the test";
string = string.split( " " );
a) an array containing the strings "Good", "luck", "on", "the" and "test"
b) the string "Good.luck.on.the.test"
c) the string "Good,luck,on,the,test"
d) Nothing, the string conversion will generate an error.
ans)option A correct
27. What is the value of s3 after the following code is executed?
var s1 = “one”;
var s2 = “two”;
var s3 = “three”;
s1.concat( s2 );
s3 = s1;
a) one
b) onetwo
c) three
d) onetwothree
ans)option B correct
28. Which of the following methods would you use to search a string for a specific character?
a) substring
b) charAt
c) substr
d) indexOf
ans)option D correct
29. The window object includes the method _____ for creating new browser windows.
a) new
b) open
c) create
d) spawn
ans) option B correct
30. Method _____ of the window object provides a way to ask users for input.
a) close
b) response
c) ask
d) prompt
ans)option D correct
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.