johngrit
09-04-2008, 07:47 PM
Doing a multiple choice paper, just need clarification on a few questions...
Any help would be much appreciated...I am a bit of a novice on this
1.
Consider this informal description of some instructions:
if (__________________)
document.write(aNumber is between 1 and 10 inclusive)
else
document.write(aNumber is less than 1 or greater than 10)
Which of the following Boolean conditions could be used to test correctly
the value of aNumber? You can assume that aNumber has been properly
declared and holds an integer value. (Select one option.)
A. (aNumber >= 1) || (aNumber <= 10)
B. (aNumber < 1) || (aNumber > 10)
C. (aNumber >= 1) && (aNumber <= 10)
D. (aNumber > 1) && (aNumber < 10)
2.
Consider the following compound condition:
Y AND (X AND Y)
Which of the following is equivalent to it? (Select one option.)
A. X OR Y
B. X
C. Y AND X
D Y
3.
Consider the following JavaScript program
var number;
number = window.prompt('please enter a number between 1 and 10', '0');
number = parseFloat (number);
if ((number == 1) || (number == 3) || (number == 5))
{
document.write('You have won 2 pounds')
}
else if ((number == 2) || (number != 6))
{
document.write('You have won 4 pounds')
}
else
{
document.write('You have won 8 pounds')
}
What will be displayed if you enter 6 in response to the prompt when the program is run? (Select one option.)
A. You have won 2 pounds
B. You have won 4 pounds
C. You have won 6 pounds
D. You have won 8 pounds
4.
Consider the following fragment of JavaScript
var a = 7;
var b = 4;
var c = a - b;
number = 2 * (16 - b) / 6 + (a * (9 + c) + (c - a));
document.write (number);
What will be displayed when the program is run? (Select one option.)
A. 12
B. 109
C. 44
D. 84
E. Undefined
5.
In which of the following places would you expect to find the definition of a JavaScript event handler function to respond to a button click event?
(Select one option.)
A. After the ONCLICK keyword in the button declaration.
B. In a SCRIPT section in the HEAD of the HTML page where the button is declared.
C. In a SCRIPT section in the BODY of the HTML page where the button is declared.
D. In the FORM declaration which contains the button declaration.
6.
Consider this fragment of JavaScript:
var numArray = [9 , 8 , 7 , 6 , 5];
writeArray ();
function writeArray ()
{
var numArray = [1 , 2 , 3 , 4 , 5 , 6];
for (var count = 1; count < 6; count = count + 1)
document.write(numArray[count] + ' ');
}
What will be displayed when the program is run? (Select one option.)
A. 1 2 3 4 5 6
B. 9 8 7 6 5
C. 2 3 4 5 6
D. 9 8 7 6 5 Undefined
Any help would be much appreciated...I am a bit of a novice on this
1.
Consider this informal description of some instructions:
if (__________________)
document.write(aNumber is between 1 and 10 inclusive)
else
document.write(aNumber is less than 1 or greater than 10)
Which of the following Boolean conditions could be used to test correctly
the value of aNumber? You can assume that aNumber has been properly
declared and holds an integer value. (Select one option.)
A. (aNumber >= 1) || (aNumber <= 10)
B. (aNumber < 1) || (aNumber > 10)
C. (aNumber >= 1) && (aNumber <= 10)
D. (aNumber > 1) && (aNumber < 10)
2.
Consider the following compound condition:
Y AND (X AND Y)
Which of the following is equivalent to it? (Select one option.)
A. X OR Y
B. X
C. Y AND X
D Y
3.
Consider the following JavaScript program
var number;
number = window.prompt('please enter a number between 1 and 10', '0');
number = parseFloat (number);
if ((number == 1) || (number == 3) || (number == 5))
{
document.write('You have won 2 pounds')
}
else if ((number == 2) || (number != 6))
{
document.write('You have won 4 pounds')
}
else
{
document.write('You have won 8 pounds')
}
What will be displayed if you enter 6 in response to the prompt when the program is run? (Select one option.)
A. You have won 2 pounds
B. You have won 4 pounds
C. You have won 6 pounds
D. You have won 8 pounds
4.
Consider the following fragment of JavaScript
var a = 7;
var b = 4;
var c = a - b;
number = 2 * (16 - b) / 6 + (a * (9 + c) + (c - a));
document.write (number);
What will be displayed when the program is run? (Select one option.)
A. 12
B. 109
C. 44
D. 84
E. Undefined
5.
In which of the following places would you expect to find the definition of a JavaScript event handler function to respond to a button click event?
(Select one option.)
A. After the ONCLICK keyword in the button declaration.
B. In a SCRIPT section in the HEAD of the HTML page where the button is declared.
C. In a SCRIPT section in the BODY of the HTML page where the button is declared.
D. In the FORM declaration which contains the button declaration.
6.
Consider this fragment of JavaScript:
var numArray = [9 , 8 , 7 , 6 , 5];
writeArray ();
function writeArray ()
{
var numArray = [1 , 2 , 3 , 4 , 5 , 6];
for (var count = 1; count < 6; count = count + 1)
document.write(numArray[count] + ' ');
}
What will be displayed when the program is run? (Select one option.)
A. 1 2 3 4 5 6
B. 9 8 7 6 5
C. 2 3 4 5 6
D. 9 8 7 6 5 Undefined