What will be the output of the following program?
Java
int[] arr = {5, 10, 15, 20, 25};
int sum = 0;
for (int num : arr) {
sum += num;
}
System.out.println(sum);
How do you find the largest element in an array in Java?
Using Collections.max(arr)
Iterating and comparing each element
Sorting and taking the first element
What will be the output of the following code?
Java
int[] arr = {3, 1, 4, 1, 5, 9};
Arrays.sort(arr);
System.out.println(arr[0]);
What is the best way to reverse an array in Java?
Using Collections.reverse()
Using a loop with swapping
What will be the output of the following program?
Java
int[] arr = {1, 2, 3, 4, 5};
System.out.println(arr.length);
How do you check if two arrays are equal in Java?
Arrays.equals(arr1, arr2)
What will be the output of the following program?
Java
int[] arr1 = {1, 2, 3};
int[] arr2 = arr1;
arr2[0] = 10;
System.out.println(arr1[0]);
What is the correct way to copy an array in Java?
arr2 = Arrays.copyOf(arr1, arr1.length);
How do you find duplicate elements in an array?
Java does not support duplicate detection
What is the time complexity of linear search in an array?
There are 10 questions to complete.
Take a part in the ongoing discussion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4