Java Array MCQs with answers Page - 6

You will find multiple-choice questions (MCQs) related to #Java Array here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 825.56K Points
Coach

Q. How to find the largest element in an array?

  • (A) Use Arrays.max()
  • (B) Use array.sort()
  • (C) Use a loop and compare
  • (D) Use array.max()

A

Admin • 825.56K Points
Coach

Q. What is the time complexity to access an array element by index?

  • (A) O(n)
  • (B) O(log n)
  • (C) O(1)
  • (D) O(n log n)

A

Admin • 825.56K Points
Coach

Q. Which of these supports dynamic resizing?

  • (A) Array
  • (B) ArrayList
  • (C) String[]
  • (D) int[]

A

Admin • 825.56K Points
Coach

Q. Which loop is used to access each element without index in an array?

  • (A) for-each
  • (B) while
  • (C) do-while
  • (D) standard for loop

A

Admin • 825.56K Points
Coach

Q. Which of the following is the correct syntax to declare and initialize a 2D array?

  • (A) int arr[][] = {{1,2},{3,4}};
  • (B) int[][] arr = new int[2,2];
  • (C) int[][] arr = [2][2];
  • (D) int arr = new int[2][2] = {{1,2},{3,4}};

A

Admin • 825.56K Points
Coach

Q. Which keyword is used to create a new array object in memory?

  • (A) create
  • (B) array
  • (C) new
  • (D) allocate

A

Admin • 825.56K Points
Coach

Q. How to clone an array in Java?

  • (A) arr.duplicate()
  • (B) arr.clone()
  • (C) Arrays.copy(arr)
  • (D) arr.copy()

A

Admin • 825.56K Points
Coach

Q. Which of the following is a rectangular 2D array?

  • (A) new int[3][]
  • (B) new int[3][4]
  • (C) new int[][]{{1},{2,3}}
  • (D) int[][] = {{}}

A

Admin • 825.56K Points
Coach

Q. Can array variables be reassigned to a different array?

  • (A) No, it's not allowed
  • (B) Yes, if the size is same
  • (C) Yes, regardless of size
  • (D) Only inside constructors

A

Admin • 825.56K Points
Coach

Q. What is the output?
int[] x = {1,2,3};
System.out.println(x[1] + x[2]);

  • (A) 2
  • (B) 3
  • (C) 5
  • (D) 6
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More