QuestionQuestion

Question 1
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)

Question 2
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 )

Question 3
The first statement below ________ the array while the second statement ________ the array.
var c;
a. declares, initializes
b. initializes, declares
c. declares, allocates
d. allocates, declares

Question 4
In JavaScript, all objects and arrays are passed to functions by ________.
a. value
b. parameters
c. memory
d. reference

Question 5
_________ are data structures consisting of related data items (sometimes called collections of data items).
a. lvalues
b. composites
c. arrays
d. databases

Question 6
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 );

Question 7
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

Question 8
Pass-by- ________ is the method of passing a copy of the argument's value to a function.
a. value
b. parameters
c. memory
d. reference

Question 9
To refer to a particular location or element in the array, we specify the name of the array and the ________ of the particular element in the array.
a. contents
b. size
c. subscript
d. type

Question 10
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 ;

.............................................

Question 1
In a worst-case scenario, searching an array of 1023 elements will take only ________ comparisons using a binary search.
a. 1000
b. 100
c. 50
d. 10

Question 2
In JavaScript, numbers and boolean values are passed to functions by ________.
a. value
b. parameters
c. memory
d. reference

Question 3
What does the following code do?
for ( var col = 0; col < a[ 2 ].length; ++col )
a[ 2 ][ col ] = 0;
a. Sets the rows and columns to zero.
b. Sets the rows to zero.
c. Sets the columns to zero.
d. Sets all the elements in the third row to zero.

Question 4
What would the browser output if the following script is executed?
<script type = "text/javascript">
<!--
var array = [ [ 1, 2, 3 ], [ 1, 2, 3 ] ];
for ( var i in array )
{
for ( var j in array[ i ] )
document.write( array[ i ][ j ] + " " );
document.writeln("<br />");
}
//-->
</script>
a. Nothing, the script would generate an error
b. 1 2 3
c. 1 2 34 5 6
d. 1 2 31 2 3

Question 5
By default, the JavaScript sort method uses ________ to sort the array passed to it.
a. string comparison
b. binary search
c. linear search
d. bubble sort

Question 6
Property _______ will be true for the radio button chosen by the user.
a. selected.
b. checked.
c. check.
d. clicked.

Question 7
What is the effect of the join statement in the following code?
var theArray1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
var theArray2 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
var value = theArray1.join( " " );
a. The join method will concatenate the values of theArray2 to theArray1.
b. The join method will concatenate the values of theArray1 to theArray2.
c. The join method will create a string from the values in theArray1.
d. The join method will create a string with the values of theArray2 concatenated to the values of theArray1.

Question 8
What will the browser display if the following script is executed?
var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
modifyArray( theArray[ 3 ] );
document.write( theArray.join( " " ) );

function modifyArray( i )
{
i = 11;
}
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

Question 9
After each comparison, the binary search algorithm eliminates ________ of the elements in the array remaining to be searched.
a. all
b. half
c. none
d. a specified amount

Question 10
The sort method can be given a function to use for the comparisons it makes, called a(n) ________ function.
a. isLessThan
b. compare
c. compareTo
d. comparator

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Question 1: The answer is option C.
Question 2: The answer is option B.
Question 3: The answer is option C....
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Web Development (HTML, XML, PHP, JavaScript, Adobe, Flash, etc.) Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats