Java Array MCQs with answers Page - 5

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. Which of the following statements about Java arrays is FALSE?

  • (A) Arrays can store primitive types
  • (B) Arrays can store objects
  • (C) Arrays can change size after creation
  • (D) Arrays are indexed from 0

A

Admin • 828.03K Points
Coach

Q. How do you create an array of 5 Strings?

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

A

Admin • 828.03K Points
Coach

Q. Which method converts an array to a string representation?

  • (A) Arrays.toString()
  • (B) array.toText()
  • (C) String.valueOf()
  • (D) toString() directly on array

A

Admin • 828.03K Points
Coach

Q. What is the result of accessing an uninitialized index in a String array?

  • (A) null
  • (B) 0
  • (C) undefined
  • (D) Compile-time error

A

Admin • 828.03K Points
Coach

Q. What does this code print?
int[] arr = {1,2,3};
System.out.println(arr);

  • (A) 1 2 3
  • (B) [1, 2, 3]
  • (C) Class name and hashcode
  • (D) Error

A

Admin • 828.03K Points
Coach

Q. Which statement is used to copy arrays?

  • (A) array.copy()
  • (B) System.arraycopy()
  • (C) Arrays.clone()
  • (D) array.duplicate()

A

Admin • 828.03K Points
Coach

Q. What will this code output?
char[] ch = {'A','B','C'};
System.out.print(ch[1]);

  • (A) A
  • (B) B
  • (C) C
  • (D) Index out of bounds

A

Admin • 828.03K Points
Coach

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

  • (A) 0
  • (B) 0.0
  • (C) null
  • (D) NaN

A

Admin • 828.03K Points
Coach

Q. What does this print?
int[] a = new int[]{1, 2};
System.out.println(a.length);

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

A

Admin • 828.03K Points
Coach

Q. Which of the following is true about array declaration?

  • (A) int arr = new int[];
  • (B) int[] arr = new int[0];
  • (C) int arr[0] = new int[];
  • (D) int arr = [10];
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