InterviewSolution
Saved Bookmarks
| 1. |
What Is The Output Of This Program? 1. Import Java.util.*; 2. Class Array { 3. Public Static Void Main(string Args[]) { 4. Int Array[] = New Int [5]; 5. For (int I = 5; I > 0; I--) 6. Array[5-i] = I; 7. Arrays.fill(array, 1, 4, 8); 8. For (int I = 0; I < 5 ; I++) 9. System.out.print(array[i]); 10. } 11. } |
|
Answer» ARRAY was containing 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 5,8,8,8,1. Output: $ JAVAC Array.java array was containing 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 5,8,8,8,1. Output: $ javac Array.java |
|