Question | Option A | Option B | Option C | Option D |
What is the default value of an element in an array of int in Java? | Null_ | 0 | 1 | -1 |
Which of the following correctly declares an array in Java? | int arr[] = new int(5); | int[] arr = new int[5]; | int arr[5]; | int arr[] = int[5]; |
What happens if you try to access an array index out of bounds in Java? | Compilation error | Program runs with no error | ArrayIndexOutOfBoundsException | NullPointerException |
What is the time complexity for accessing an element from an array by its index? | O(n) | O(log n) | O(1) | O(n^2) |
Which of the following methods can be used to sort an array in Java? | Arrays.sort(arr) | Collections.sort(arr) | Sort(arr) | arr.sort() |
|
No comments:
Post a Comment