Question: ____________________________________________________________ public class LabArray { /****************************************************** * Follow the instructions in main * the expected output is listed at the end of this file *******************************************************/

____________________________________________________________

public class LabArray

{

/******************************************************

* Follow the instructions in main

* the expected output is listed at the end of this file

*******************************************************/

public static void main(String[] args)

{

// create int array named intArray of size 3

// use the method printArray to print the array; pass as name

"intArray"

// assign the value 2 to the first element

// use the field length to assign the value 4 to the last element

// print all elements of intArray

// in a separate line print the lenght of intArray

// create an integer variable named number and assign it the value 3

// assign number plus 4 (as an expression) to the second element of

intArray

// assign the value of the first element to the third element of

intArray

// print all elements of intArray

}

private static void printArray(int[] integerArray, String name)

{

System.out.printf("%s: ", name);

for (int i = 0; i < integerArray.length; i++)

{

System.out.printf("%d ", integerArray[i]);

}

System.out.println();

}

/*****************************

* Expected Output:

*

* intArray: 0 0 0

* intArray: 2 0 4

* length of intArray: 3

* intArray: 2 7 2

******************************/

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!