SlideShare a Scribd company logo
1. Which of the following statements would correctly print out the sentence “Hello World” in
blue?
a) document.write( “
”);
b) document.write( “
style = ”color: blue” Hello World );
c) document.write( “
”);
d) document.write( “
”);
document.write( “Hello World ”);
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( “ Welcome! ” );
3. Consider the following script. What is wrong with the following code?
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?
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?
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?
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?
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( “
”);
b) document.write( “
style = ”color: blue” Hello World );
c) document.write( “
”);
d) document.write( “
”);
document.write( “Hello World ”);
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( “ Welcome! ” );
3. Consider the following script. What is wrong with the following code?
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?
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?
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?
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?
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( “
”);
b) document.write( “
style = ”color: blue” Hello World );
c) document.write( “
”);
d) document.write( “
”);
document.write( “Hello World ”);
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( “ Welcome! ” );
3. Consider the following script. What is wrong with the following code?
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?
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?
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?
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?
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
Solution
1. Which of the following statements would correctly print out the sentence “Hello World” in
blue?
a) document.write( “
”);
b) document.write( “
style = ”color: blue” Hello World );
c) document.write( “
”);
d) document.write( “
”);
document.write( “Hello World ”);
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( “ Welcome! ” );
ans)option A correct
3. Consider the following script. What is wrong with the following code?
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?
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?
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?
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?
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

More Related Content

DOCX
ExamName___________________________________MULTIPLE CH.docx
PDF
MATLAB Questions and Answers.pdf
DOCX
(Www.entrance exam.net)-tcs placement sample paper 2
PDF
PDF
C mcq practice test 1
PDF
JavaScript MCQ (JS Coding Questions and Answers)
DOCX
Data structures and algorithms unit i
PDF
Anomalies in X-Ray Engine
ExamName___________________________________MULTIPLE CH.docx
MATLAB Questions and Answers.pdf
(Www.entrance exam.net)-tcs placement sample paper 2
C mcq practice test 1
JavaScript MCQ (JS Coding Questions and Answers)
Data structures and algorithms unit i
Anomalies in X-Ray Engine

Similar to 1. Which of the following statements would correctly print out t.pdf (20)

DOCX
Mouse programming in c
DOCX
Technical questions
DOCX
Name _______________________________ Class time __________.docx
DOCX
Java Questioner for
PDF
Analysis of Microsoft Code Contracts
PDF
Session 5-exersice
PDF
Of complicacy of programming, or won't C# save us?
PDF
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
PDF
Model question paper_mc0061
DOC
PDF
C Programming Interview Questions
PDF
1z0 851 exam-java standard edition 6 programmer certified professional
DOCX
Comp 328 final guide
PDF
C multiple choice questions and answers pdf
PDF
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
PDF
important C questions and_answers praveensomesh
DOC
C-programs
PDF
Computer Project For Class XII Topic - The Snake Game
DOCX
39927902 c-labmanual
DOCX
39927902 c-labmanual
Mouse programming in c
Technical questions
Name _______________________________ Class time __________.docx
Java Questioner for
Analysis of Microsoft Code Contracts
Session 5-exersice
Of complicacy of programming, or won't C# save us?
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
Model question paper_mc0061
C Programming Interview Questions
1z0 851 exam-java standard edition 6 programmer certified professional
Comp 328 final guide
C multiple choice questions and answers pdf
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
important C questions and_answers praveensomesh
C-programs
Computer Project For Class XII Topic - The Snake Game
39927902 c-labmanual
39927902 c-labmanual
Ad

More from ezzi97 (20)

PDF
Explain why multiple processes cannot share data easilySolution.pdf
PDF
executive summary for law enforcement using dronesSolutionUse .pdf
PDF
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
PDF
create a narrative budget blueprint for a local unit of government. .pdf
PDF
define three types of kernal-mode to user mode transfersSolution.pdf
PDF
Arrange the steps of DNA replication in the order that they occur. D.pdf
PDF
C++You will design a program to play a simplified version of war, .pdf
PDF
(c) After conducting several measurements, the Beijing Municipal Env.pdf
PDF
2.How important is it to involve physicians in financial improvement.pdf
PDF
Write one page essay to explain how you relate signals and systems t.pdf
PDF
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
PDF
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
PDF
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
PDF
Who are stakeholders Define who they are and then please share what.pdf
PDF
What was the biggest problem with the Articles of Confederation They.pdf
PDF
What is UWIN and what does it doSolutionUWin is a software .pdf
PDF
What sort of archaeological remains have been discovered on the site.pdf
PDF
Link to assignment that I need help with is below httpweb.cse..pdf
PDF
The Food Stamp Program is Americas first line of defense against hu.pdf
PDF
The following code snipet contains some unfamiliar text#include .pdf
Explain why multiple processes cannot share data easilySolution.pdf
executive summary for law enforcement using dronesSolutionUse .pdf
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
create a narrative budget blueprint for a local unit of government. .pdf
define three types of kernal-mode to user mode transfersSolution.pdf
Arrange the steps of DNA replication in the order that they occur. D.pdf
C++You will design a program to play a simplified version of war, .pdf
(c) After conducting several measurements, the Beijing Municipal Env.pdf
2.How important is it to involve physicians in financial improvement.pdf
Write one page essay to explain how you relate signals and systems t.pdf
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
Who are stakeholders Define who they are and then please share what.pdf
What was the biggest problem with the Articles of Confederation They.pdf
What is UWIN and what does it doSolutionUWin is a software .pdf
What sort of archaeological remains have been discovered on the site.pdf
Link to assignment that I need help with is below httpweb.cse..pdf
The Food Stamp Program is Americas first line of defense against hu.pdf
The following code snipet contains some unfamiliar text#include .pdf
Ad

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Classroom Observation Tools for Teachers
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
Cell Types and Its function , kingdom of life
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
01-Introduction-to-Information-Management.pdf
PDF
Trump Administration's workforce development strategy
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Classroom Observation Tools for Teachers
O7-L3 Supply Chain Operations - ICLT Program
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Module 4: Burden of Disease Tutorial Slides S2 2025
VCE English Exam - Section C Student Revision Booklet
Final Presentation General Medicine 03-08-2024.pptx
GDM (1) (1).pptx small presentation for students
STATICS OF THE RIGID BODIES Hibbelers.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Cell Types and Its function , kingdom of life
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
A systematic review of self-coping strategies used by university students to ...
01-Introduction-to-Information-Management.pdf
Trump Administration's workforce development strategy

1. Which of the following statements would correctly print out t.pdf

  • 1. 1. Which of the following statements would correctly print out the sentence “Hello World” in blue? a) document.write( “ ”); b) document.write( “ style = ”color: blue” Hello World ); c) document.write( “ ”); d) document.write( “ ”); document.write( “Hello World ”); 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( “ Welcome! ” ); 3. Consider the following script. What is wrong with the following code? 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? a) nothing b) 0 c) 10
  • 2. 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 )
  • 3. 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? 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? a) Nothing; the browser would generate an error.
  • 4. 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 ________.
  • 5. 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? a) Nothing, the browser will generate an error. b) 1 2 3 4 5 6 7 8 9
  • 6. 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
  • 7. 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( “ ”); b) document.write( “ style = ”color: blue” Hello World ); c) document.write( “ ”); d) document.write( “ ”); document.write( “Hello World ”); 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( “ Welcome! ” ); 3. Consider the following script. What is wrong with the following code? 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?
  • 8. 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
  • 9. 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? a) Nothing; the browser would generate an error. b) 0 c) 50 d) 60
  • 10. 14. What would the browser display if the following script were executed? 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
  • 11. 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?
  • 12. 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
  • 13. 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( “ ”); b) document.write( “ style = ”color: blue” Hello World ); c) document.write( “ ”); d) document.write( “ ”); document.write( “Hello World ”); 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( “ Welcome! ” ); 3. Consider the following script. What is wrong with the following code? 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
  • 14. prompts? 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
  • 15. 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? a) Nothing; the browser would generate an error. b) 0
  • 16. c) 50 d) 60 14. What would the browser display if the following script were executed? 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
  • 17. 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
  • 18. d) 10 24. What will the browser display if the following script is executed? 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
  • 19. 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 Solution 1. Which of the following statements would correctly print out the sentence “Hello World” in blue? a) document.write( “ ”); b) document.write( “ style = ”color: blue” Hello World ); c) document.write( “ ”); d) document.write( “ ”); document.write( “Hello World ”); 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( “ Welcome! ” ); ans)option A correct 3. Consider the following script. What is wrong with the following code?
  • 20. 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? 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
  • 21. 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
  • 22. 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 );
  • 23. 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? 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? 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
  • 24. 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
  • 25. 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
  • 26. 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? 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"
  • 27. 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