Ask Question
15 October, 19:46

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.

+1
Answers (1)
  1. 15 October, 20:12
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers