-
What is the output of this program?
import java.util.*;
public class Array_Examle
{
public static void main(String args[])
{
int p[] = new int [10];
for (int k = 7; k > 0 ; k--)
{
p[7-k] = k;
}
Arrays.fill(p, 1, 4, 8);
for (int k = 0; k < 5 ; k++)
{
System.out.print(p[k]);
}
}
}
-
- 56885
- 678867
- 328832
- 78883
- 68883
Correct Option: D
array was containing 7,6,5,4,3,2,1 but when method Arrays.fill(array, 1, 4, 8) is called it fills the index location starting with 1 to 4 by value 8 hence array becomes 7,8,8,8,3.