Ask Question
17 April, 12:28

printArray is a method that accepts one argument, an arrayof int. The method prints the contents of the array; it does not return a value. inventory is an array of int that has been already declared and filled with values. Write a statementthat prints the contents of the array inventory by calling the method printArray using a declared and instantiated object named obj.

+4
Answers (1)
  1. 17 April, 12:48
    0
    public class ArrayTest {

    public static void main (String[] args) {

    int [ ] inventoryArray = {2,34,45,65,78,78,100};

    Array obj = new Array ();

    obj. printArray (inventoryArray);

    //new Array (). printArray (inventoryArray);

    }

    }

    class Array {

    public void printArray (int []arr) {

    for (int i = 0; i
    System. out. print (arr[i]);

    System. out. print (" ");

    }

    }

    }

    Explanation:

    Two classes are created Array and ArrayTest The class Array has the method printArray that accept an argument array and prints the contents using a for loop. In the class ArrayTest, and array is created and initialized with some values called inventoryArray. An object of the Array class is created and named obj the method printArray of the Array class is called and passed the created inventoryArray. This prints the values to the screen
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “printArray is a method that accepts one argument, an arrayof int. The method prints the contents of the array; it does not return a value. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers