Java Array MCQs with answers Page - 2

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 • 828.03K Points
Coach

Q. How are arrays stored in memory in Java?

  • (A) Contiguous blocks
  • (B) Scattered blocks
  • (C) Linked list
  • (D) Tree structure

A

Admin • 828.03K Points
Coach

Q. Can arrays hold objects in Java?

  • (A) Yes
  • (B) No
  • (C) Only in 2D arrays
  • (D) Only primitive arrays can

A

Admin • 828.03K Points
Coach

Q. What is returned by arr.length for an array arr = new int[10]?

  • (A) 9
  • (B) 10
  • (C) 11
  • (D) undefined

A

Admin • 828.03K Points
Coach

Q. Can you resize an array in Java after creation?

  • (A) Yes
  • (B) No
  • (C) Only if it's an object array
  • (D) Only using loops

A

Admin • 828.03K Points
Coach

Q. Which of the following initializes an array with values?

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

A

Admin • 828.03K Points
Coach

Q. What is the data type of elements in this array?
String[] names = new String[5];

  • (A) char
  • (B) String
  • (C) Object
  • (D) Array

A

Admin • 828.03K Points
Coach

Q. What exception is thrown when accessing an invalid index in an array?

  • (A) NullPointerException
  • (B) IndexException
  • (C) IllegalAccessError
  • (D) ArrayIndexOutOfBoundsException

A

Admin • 828.03K Points
Coach

Q. Which loop is best suited for iterating over an array?

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

A

Admin • 828.03K Points
Coach

Q. How do you declare a 3D array in Java?

  • (A) int arr[][][] = new int[3][3][3];
  • (B) int arr[3][3][3];
  • (C) int arr = new int[3,3,3];
  • (D) int[3][3][3] arr;

A

Admin • 828.03K Points
Coach

Q. Which of the following is false about Java arrays?

  • (A) They are objects
  • (B) They can store mixed data types
  • (C) They are fixed in size
  • (D) They are zero-indexed
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