Ask 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. 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.

+2
Answers (1)
  1. 12 October, 11:49
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers