Question

1. Given the following array, what is the value of pets[3]? var pets = new Array("giraffe",...

1. Given the following array, what is the value of pets[3]?

var pets = new Array("giraffe", "pig", "beetle", "hamster", "spider", "goldfish", "cow");

A. pig

B. beetle

C. hamster

D. spider

2. Given the following array, which statement will create a variable named product that multiplies 4 * 5, using array elements?

var nums = new Array(2, 3, 4, 5, 6, 30, 40, 50, 60);

A. var product = nums[1] * nums[2];

B. var product = nums[2] * nums[3];

C. var product = nums[3] * nums[4];

D. var product = nums[4] * nums[5];

3. Which statement will add the value stored in the variable pizza to the food() array given below?

var food = new Array("burger", "chips", "subs", "lasagna");

var pizza = "pepperoni pizza";

A. food[0] = pizza;

B. pizza.push(food);

C. food.push(pizza);

D. This cannot be done.

4. Assume the variables x, y, and temp have previously been declared as numeric variables. If initially x = 2 and y = 6, what is the value of temp after the following code is executed?

temp = x;

y = temp;

x = y;


A. 2

B. 6

C. NaN

D. It is impossible to tell from this code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

Ans: (c) hamster

pets[0]="giraffe" ,pets[1]="pig" ,pets[2]="beetle" ,pets[3]="hamster"

so, hamster will be printed.

2.

Ans: (b). var product = nums[2] * nums[3];

because nums[2]=4 and nums[3] =5

so, nums[2] *nums[3] = 4*5 =20

3.

Ans: (c). food.push(pizza)

Because here array is food so, by using push operation we push pizza ro food by using

food.push(pizza) operation.

4.

Ans: (a) 2

because initially x=2 and y=6

here, temp=x now temp becomes 2 i.e., temp=2

y=temp now y beomces 2 i.,e, y=2

x=y now x becomes y i.e., x=2

so, final value of temp is 2

Add a comment
Know the answer?
Add Answer to:
1. Given the following array, what is the value of pets[3]? var pets = new Array("giraffe",...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Assuming each line of information is stored in a new array, which of the following...

    1. Assuming each line of information is stored in a new array, which of the following pairs are not parallel arrays? A. names of all students at Santa Fe College ID numbers of all students at Santa Fe College B. names of all students at Santa Fe College names of all students taking JavaScript at Santa Fe College C. names of all students at Santa Fe College email addresses of all students at Santa Fe College D. All three sets...

  • 1. Which of the following code snippets will load an array named fives(), consisting of 10...

    1. Which of the following code snippets will load an array named fives(), consisting of 10 elements with the starting value of the first element = 0 and will load each subsequent element counting by 5's, ending with the last element = 45. In other words, the elements in the fives() array should be (0, 5, 10, 15, ... 45).   A. var fives = new Array(); for(j = 1; j < 11; j++)      fives[j] = j + 5; B. var...

  • Python: problem 1 Given an array of integers, return the sum of two indices from this...

    Python: problem 1 Given an array of integers, return the sum of two indices from this array based on input parameters, x and y. Example: Given nums = [2, 7, 11, 15], x = 3, y = 1 Because nums[x] + nums[y] = 15 + 7 = 22, return 22. You may use this as a template for your code class Solution: def two_sum(self, nums: List[int], x: int, y: int) -> int:

  • 1. True or False: The selection sort cannot be used to sort strings. A. True B....

    1. True or False: The selection sort cannot be used to sort strings. A. True B. False 2. The __________ search is most efficient for large amounts of data. A. binary B. serial C. selection D. bubble 3. What will be displayed after the following code is executed? var chips = new Array("plain", "onion", "tuna", "barbecue", "cheddar"); document.write("There are " + chips.length + 1 + " types of chips."); document.write("My favorite is " + chips[2] + "."); A. There are...

  • Given Var(X) = 4, Var(Y) = 1, and Var(X+2Y) = 10, What is Var(2X-Y-3)? I know...

    Given Var(X) = 4, Var(Y) = 1, and Var(X+2Y) = 10, What is Var(2X-Y-3)? I know the answer is 15, I'm particularly interested in the specific steps involved with finding the cov(X,Y) in this problem. Please explain in detail, step by step how you come to cov(X,Y) = 0.5 in this equation. Please include any formulas you would need to use to find the cov(X,Y) in this equation.

  • Given the following JavaScript code, what will be displayed on the web page? var pho =...

    Given the following JavaScript code, what will be displayed on the web page? var pho = new Array(); for (var i = 0; i< 7; i++) {      pho[i] = (i*i) + 3; }            for (var i = 0; i< 7; i++) {      document.write(i + " => " + pho[i] + "<br>"); } 1 => 4 2 => 7 3 => 12 4 => 19 5 => 28 6 => 39

  • 1. var s = "A red boat"; var a = s.split(" "); what is the value...

    1. var s = "A red boat"; var a = s.split(" "); what is the value of a? var b = [9, 3, 2, 1, 3, 7]; var c = b.slice(2, 5); What is the value of c? var d = c.concat(a); alert(d.join("**")); [ 'A', 'red' , 'boat'] [ 2 , 1, 3] 2**1**3**A**red**boat [ 'A', 'red' , 'boat'] [ 1 , 3, 7] 8**A**red**boat [ 'A', 'red' , 'boat'] [ 3 , 2, 1] A**red**boat [ 'A', 'red' ,...

  • QUESTION 9 Given E(X)=2 and Var(X)=4, let Y =5X-3. Find E(Y) Var(Y)

    QUESTION 9 Given E(X)=2 and Var(X)=4, let Y =5X-3. Find E(Y) Var(Y)

  • 1.arrayList[9] accesses the 10th object of an array of length 10 true false 2. Arrays are...

    1.arrayList[9] accesses the 10th object of an array of length 10 true false 2. Arrays are the only data structure that can be accessed with [ ]; for example: orderedData[0] true false 3. In a maximum of three steps: how do you swap the contents between two variables of the same type? Pick the absolute best answer A temp = x; x = y; y = temp B x = x + y; y = x - y; x =...

  • IN JAVA please Given a sorted array and a target value, return the index if the...

    IN JAVA please Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. Your code will be tested for runtime. Code which does not output a result in logarithmic time (making roughly log(2) N comparisons) will fail the tests. A sample main function is provided so that you may test your code on sample inputs. For testing purposes, the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT