The program is an illustration of arrays.
Arrays are used to hold multiple values.
The program in java, where comments are used to explain each line is as follows:
import java.util.*;
public class Main{
//This defines the method
public static int[] swapValues(int[] arr) {
//This swaps the first and second array elements
int temp = arr[0];
arr[0] = arr[1]; arr[1] = temp;
//This swaps the third and fourth array elements
temp = arr[2];
arr[2] = arr[3]; arr[3] = temp;
//This returns the swapped array to main
return arr;
}
//The main method begins here
public static void main(String[] args) {
//This creates a Scanner object
Scanner input = new Scanner(System.in);
//This declares an array of 4 elements
int[] intArray = new int[4];
//This gets input for the array
for(int i = 0; i<4;i++){
intArray[i] = input.nextInt();
}
//This calls the swapValues method
intArray=swapValues(intArray);
//This prints the swapped array
for (int i = 0; i < 4; i++){
System.out.print( intArray[i]+ " "); }
}
}
At the end of the program, the elements are swapped and printed.
Read more about similar programs at:
brainly.com/question/14017034