Java Array MCQs with answers Page - 7

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. What is the result of this code?
int[] arr = new int[]{1, 2, 3};
System.out.println(arr[3]);

  • (A) 3
  • (B) 0
  • (C) ArrayIndexOutOfBoundsException
  • (D) null

A

Admin • 825.56K Points
Coach

Q. Which of the following creates a jagged array in Java?

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

A

Admin • 825.56K Points
Coach

Q. What is printed?
int[] a = new int[3];
a[0] = 5;
System.out.println(a[0]);

  • (A) 5
  • (B) 0
  • (C) 1
  • (D) null

A

Admin • 825.56K Points
Coach

Q. Which keyword is used to allocate memory for an array?

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

A

Admin • 825.56K Points
Coach

Q. Which class contains utility methods for array operations?

  • (A) ArrayUtils
  • (B) ArrayHelper
  • (C) Arrays
  • (D) Collections

A

Admin • 825.56K Points
Coach

Q. Which of these is the correct syntax to declare an array of doubles?

  • (A) double arr[];
  • (B) double[] arr;
  • (C) Both A and B
  • (D) None of the above

A

Admin • 825.56K Points
Coach

Q. Which of the following best describes an array?

  • (A) A class
  • (B) An object
  • (C) A primitive type
  • (D) A method

A

Admin • 825.56K Points
Coach

Q. Which property is used to get the size of an array?

  • (A) size
  • (B) length()
  • (C) length
  • (D) count

A

Admin • 825.56K Points
Coach

Q. How are multidimensional arrays implemented in Java?

  • (A) As tables
  • (B) As linked lists
  • (C) As arrays of arrays
  • (D) As trees

A

Admin • 825.56K Points
Coach

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

  • (A) 2
  • (B) 3
  • (C) 1
  • (D) Error
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