21. What is the purpose of the Arrays.sort() method in Java? A. To find the maximum element in an array. B. To search for an element in an array. C. To sort the elements of an array. D. To reverse the elements of an array. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
22. How do you find the index of an element in an ArrayList named list in Java? A. list.getIndex(element); B. list.indexOf(element); C. list.find(element); D. list.search(element); Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
23. Which method is used to add an element to the end of an ArrayList in Java? A. addElement() B. insertElement() C. append() D. add() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
24. What happens when you try to access an element at an index that is out of bounds in an ArrayList in Java? A. It returns null. B. It throws an ArrayIndexOutOfBoundsException. C. It returns -1. D. It throws an IndexOutOfBoundsException. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
25. Which method is used to remove all elements from an ArrayList in Java? A. removeAllElements() B. clear() C. remove() D. deleteAll() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
26. In Java, how do you find the maximum element in an array? A. Use a loop to compare each element with the maximum value found so far. B. Use the max() method. C. Use the findMax() method. D. Use the maximum() method. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
27. Which of the following statements is true about ArrayLists in Java? A. ArrayLists can only store primitive data types. B. ArrayLists can have duplicate elements. C. ArrayLists are fixed in size. D. ArrayLists can only store Strings. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
28. How do you declare a multi-dimensional array in Java? A. int[][] matrix; B. int matrix[][]; C. int matrix[2][2]; D. All of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
29. What is the purpose of the Arrays.fill() method in Java? A. To fill an array with a specified value. B. To find the number of elements in an array. C. To copy elements from one array to another. D. To sort the elements of an array. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
30. In Java, what is the purpose of the Arrays.equals() method? A. To check if two arrays are equal. B. To concatenate two arrays. C. To find the common elements between two arrays. D. To remove duplicate elements from an array. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board