(Java) question 4 Complete the following method to insert a value into an array: public static void insert(String array[], int numElements, int indexToInsert, String newValue) { if (array.length ==...



(Java)



question 4



Complete the following method to insert a value into an array:


public static void insert(String array[], int numElements,
   int indexToInsert, String newValue) {
   if (array.length == numElements) {
      System.out.println("Array is full. No room to insert.");
      return;
   }


   //start at end and work backwards shifting names down
   for (int i = numElements; i > indexToInsert; i--) {
//fill in the missing line here

   }
   array[indexToInsert] = newValue;


}



Group of answer choices

array[i - 1] = array[i];



array[i] = array[indexToInsert];



array[indexToInsert] = array[i];



array[i] = array[i - 1];



array[i] = array[i + 1];



Complete the following method to insert a value into an array:<br>public static void insert(String array[], int numElements,<br>int indexTolnsert, String newValue) {<br>if (array.length == numElements) {<br>System.out.printIn(
indexTolnsert; i--) { //fill in the missing line here } array[indexTolnsert] = newValue; } O array[i - 1] = array[i]; O array[i] = array[indexTolnsert]; O array[indexTolnsert] = array[i]; O array[i] = array[i - 1]; O array[i] = array[i + 1]; "/>
Extracted text: Complete the following method to insert a value into an array: public static void insert(String array[], int numElements, int indexTolnsert, String newValue) { if (array.length == numElements) { System.out.printIn("Array is full. No room to insert."); return; } // start at end and work backwards shifting names down for (int i = numElements; i > indexTolnsert; i--) { //fill in the missing line here } array[indexTolnsert] = newValue; } O array[i - 1] = array[i]; O array[i] = array[indexTolnsert]; O array[indexTolnsert] = array[i]; O array[i] = array[i - 1]; O array[i] = array[i + 1];

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here