QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5, 6, 7,...

80.2K

Verified Solution

Question

Programming

QUESTION 5

  1. What is printed?

    int[] aArray = {1, 2, 3, 4};
    int[] bArray = {5, 6, 7, 8};bArray = aArray;
    System.out.print(bArray[2]);

1 points   

QUESTION 6

  1. What is printed?

    public static void main(String[] args)
     { int[] aArray = { 1, 2, 3, 4 }; System.out.print(aArray[2]);
     int i = aMeth(aArray);
     System.out.print(i + \"\" + aArray[2]);
    }
    public static int aMeth(int[] iArray)
     { for (int i = 0; i < iArray.length; i++)
     { iArray[i]++;
     } int[] bArray = { 5, 6, 7, 8 };
     iArray = bArray;
     return iArray[2];}
     
     

1 points   

QUESTION 7

  1. Assuming that array myList is properly declared and initializedwith values, what best describes the following code snippet?

    double max = myList[0];

    for (int i = 1; i < myList.length; i++) {

    if (myList[i] > max) max = myList[i];

    }

    sets max to the largest index in the array

    sets max to the index of the largest value in the array

    sets max to the largest positive value in the array

    sets max to the largest value in the array

1 points   

QUESTION 8

  1. Given the following two arrays, which of the following will copythe values from sourceArray into targetArray?

    int[] sourceArray = {2, 3, 1, 5, 10};

    int[] targetArray = new int[sourceArray.length];

    sourceArray = targetArray;

    targetArray = sourceArray;

    targetArray[] = sourceArray[];

    sourceArray.copyInto(targetArray, 0,sourceArray.length);;

    None of the above

QUESTION 1

  1. An array is an object

    True

    False

1 points   

QUESTION 2

  1. To add a new element on to the end of an arraymyArray,

    assign a new value to elementmyArray[myArray.length]

    use the myArray.add method

    use the myArray.resize method followed by themyArray.add

    new elements can't be added on to the end of an array

1 points   

QUESTION 3

  1. Assume myArray is a valid and instantiatedarray of int values. Also assume the user is asked for anint value arIndx, and enters-1.

    myArray[arIndx] = 3;

    will

    set the [-1] element of myArray to 3, even though this memoryisn't in myArray's memory

    cause a compiler error

    cause a runtime exception

    renumber myArray's elements to be from -1 tomyArray.length-2   

1 points   

QUESTION 4

  1. Note: Multiple Answer

    Which of the following will add 1 to each element of anappropriately declared, created and initialized int[]iVals?

    int i = iVals.length - 1;
    while (i >= 0)
    {
     iVals[i]++; i--;
    }
    for (int i: iVals)
    {
     i = i + 1;
    }
    for (int i: iVals)
    {
     iVals[i]++;
    }
     
    for (int i = 0; i < iVals.length; i++)
    {
     iVals[i] += 1

QUESTION 9

  1. In order to perform a binary search on an array, which of thefollowing must be true (select all that apply)?

    The array must be ordered

    The array must contain integers

    The array must have an even number of elements

    The array must have an odd number of elements

1 points   

QUESTION 10

  1. Command line arguments are made available to main() via an arrayof _______.

1 points   

QUESTION 11

  1. The first action performed in a binary search is

    Determine the largest value in the array

    Determine the smallest value in the array

    Determine the mid-point of the array

    Determine if the array is sorted

1 points   

QUESTION 12

  1. If an array contains unordered values, searching for aparticular value

    is accomplished with a linear search

    is accomplished with the bipolar search

    can't be done in Java

    requires multiple parallel processing threads

1 points   

QUESTION 13

  1. What best describes the processing of the following method?

    public static int[] mystery(int[] list) {

    int[] result = new int[list.length];

    for (int i = 0, j = result.length - 1;

           i

        result[j] = list[i];

    }

    return result;

    }

    Returns an array with the values from list sorted in ascendingorder

    Returns an array with the values from list sorted in descendingorder

    Returns an array with the values from list decremented by 1

    Returns an array with the values from list reversed

1 points   

QUESTION 14

  1. The first action performed in Selection Sort is

    convert all values to integers

    find the largest value in the array

    locate the midpoint of the array

    find the smallest value in the array

1 points   

QUESTION 15

  1. When Selection Sort is run against an array the end resultis

    the values in the array are reordered smallest to largest

    the array is unchanged because the sorted values are placed in adifferent array

    none of the other answers are correct

    the values in the array are reordered largest to smallest

Answer & Explanation Solved by verified expert
4.5 Ratings (877 Votes)
1 Answer True they are object that can be dynamically created and assigned variable values 2 Answer new elements cant be added on to the end of an array as the size of the array is fixed We can make arrays    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students