Java Array MCQs with answers Page - 4

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 printed?
String[] fruits = new String[2];
System.out.print(fruits[0]);

  • (A) null
  • (B) 0
  • (C) undefined
  • (D) empty string

A

Admin • 825.56K Points
Coach

Q. Can you assign a new array to an existing array variable?

  • (A) Yes
  • (B) No
  • (C) Only if size is same
  • (D) Only for primitive types

A

Admin • 825.56K Points
Coach

Q. Which of the following allows dynamic resizing of array-like structures?

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

A

Admin • 825.56K Points
Coach

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

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

A

Admin • 825.56K Points
Coach

Q. Which import is needed for Arrays utility class?

  • (A) import java.array.*;
  • (B) import java.util.*;
  • (C) import java.util.Arrays;
  • (D) import java.lang.Arrays;

A

Admin • 825.56K Points
Coach

Q. Which array declaration is valid?

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

A

Admin • 825.56K Points
Coach

Q. Which of the following is NOT a method in java.util.Arrays?

  • (A) sort()
  • (B) copyOf()
  • (C) toString()
  • (D) add()

A

Admin • 825.56K Points
Coach

Q. Which loop is preferred when you need both index and value from an array?

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

A

Admin • 825.56K Points
Coach

Q. What will this print?
int[] a = new int[3];
a[1] = 5;
System.out.print(a[1]);

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

A

Admin • 825.56K Points
Coach

Q. Which of the following is true about multidimensional arrays?

  • (A) They are always rectangular
  • (B) They are arrays of arrays
  • (C) They are not allowed in Java
  • (D) Only 2D arrays are supported
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