Home » JAVA Programming » Arrays » Question
  1. What is the output of this program?
    import java.util.*;
    public class ArrayExample
    {
    public static void main(String args[])
    {
    int arr[] = new int [10];
    for (int k = 10; k > 0; k--)
    arr[10 - k] = k;
    Arrays.sort(arr);
    for (int k = 0; k < 7; ++k)
    System.out.print(arr[k]);
    }
    }
    1. 1245
    2. 12345
    3. 123
    4. 123450
    5. 1234567
Correct Option: E

Arrays.sort(arr) method sorts the array into 1,2,3,4,5,6,7.



Your comments will be displayed only after manual approval.