Java Array MCQs with answers Page - 1

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 index of the first element in a Java array?

  • (A) 1
  • (B) 0
  • (C) -1
  • (D) Depends on array size

A

Admin • 825.56K Points
Coach

Q. Which of the following is a correct way to declare an array in Java?

  • (A) int arr[] = new int[5];
  • (B) array int arr = new array[5];
  • (C) int arr = new int(5);
  • (D) int[5] arr;

A

Admin • 825.56K Points
Coach

Q. What is the default value of elements in a boolean array?

  • (A) true
  • (B) false
  • (C) 0
  • (D) null

A

Admin • 825.56K Points
Coach

Q. How do you find the length of an array in Java?

  • (A) arr.length()
  • (B) arr.size()
  • (C) arr.length
  • (D) arr.getLength()

A

Admin • 825.56K Points
Coach

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

  • (A) 1
  • (B) 2
  • (C) 3
  • (D) IndexOutOfBoundsException

A

Admin • 825.56K Points
Coach

Q. Which of the following creates a two-dimensional array in Java?

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

A

Admin • 825.56K Points
Coach

Q. What is the output?
int[] arr = new int[5];
System.out.print(arr[2]);

  • (A) 0
  • (B) 2
  • (C) null
  • (D) undefined

A

Admin • 825.56K Points
Coach

Q. Which statement is true about arrays in Java?

  • (A) Arrays are dynamic in size
  • (B) Arrays can only hold primitives
  • (C) Array size is fixed after creation
  • (D) Arrays are only 1D

A

Admin • 825.56K Points
Coach

Q. What is the base type of an array declared as: int[] arr = new int[10];?

  • (A) Object
  • (B) int
  • (C) Integer
  • (D) Array

A

Admin • 825.56K Points
Coach

Q. What happens if you try to access an array index beyond its bounds?

  • (A) Returns null
  • (B) Returns 0
  • (C) Compiles but throws error at runtime
  • (D) Compiles and returns garbage value
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