Java Arrays and Multidimensional Arrays Interview MCQ Questions and Answers

Study and learn Interview MCQ Questions and Answers on Java Arrays and Multidimensional Arrays. Attend job interviews easily with these Multiple Choice Questions. You can print these Questions in default mode to conduct exams directly. You can download these MCQs in PDF format by Choosing Print Option first and Save as PDF option next using any Web Browser.

Go through Java Theory Notes Arrays and Multidimensional Arrays before reading these objective questions.



1) An Array in Java is a collection of elements of ___ data type.
A) Same
B) Different
C) -
D) -
Answer [=]
Answer[=]
2) The Java Virtual Machine (JVM) implements arrays as ___ type.
A) Primitive
B) Object
C) -
D) -
Answer [=]
Answer[=]
3) Unlike C-Arrays, the Java-Arrays have ___.
A) Names
B) Values
C) Methods and Fields
D) None
Answer [=]
Answer[=]
4) An array declaration in Java without initialization ___ memory.
A) Does not allocate
B) Allocates memory
C) -
D) -
Answer [=]
Answer[=]
5) In Java language, an array index starts with ___.
A) -1
B) 0
C) 1
D) Any integer
Answer [=]
Answer[=]
6) Which are the special symbols used to declare an array in Java?
A) Braces { }
B) Parentheses ()
C) Square Brackets [ ]
D) Angled Brackets < >
Answer [=]
Answer[=]
7) Which are the special symbols used to initialize an array at the time of the declaration itself?
A) Parentheses ( )
B) Square Brackets [ ]
C) Braces { }
D) Angled Brackets < >
Answer [=]
Answer[=]


 

8) It is possible to skip initializing some elements of the array during Shorthand Initialization. (TRUE / FALSE)
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
9) In Java, an array can be declared without initialization without mentioning the size. (TRUE / FALSE)
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
10) What is the output of the below Java code snippet with arrays?
static int[] nums; 
public static void main(String args[])
{
  System.out.println(nums.length);
}
A) 0
B) null
C) Compiler error
D) Runtime Exception - Null Pointer Exception
Answer [=]
Answer[=]
11) What is the output of the below Java program?
int[] marks = {35,65,95}; 
System.out.print(marks.length + "," + marks[1]);
A) 2,65
B) 3,95
C) 3,65
D) Compiler error
Answer [=]
Answer[=]
12) What is the output of the below Java code snippet?
int[] balls = {};
System.out.print(balls.length);
A) 0
B) -1
C) 1
D) Compiler error
Answer [=]
Answer[=]
13) Which is the correct way of knowing Array Size in Java?
A)
//int[] ary;
ary.length()
B)
//int[] ary;
ary.length
C)
//int[] ary;
ary->length()
D)
//int[] ary;
ary->length
Answer [=]
Answer[=]
14) What is the output of the below Java program with arrays?
String[] colors = {"RED";"YELLOW";"WHITE"};
System.out.print(colors[2]);
A) RED
B) YELLOW
C) WHITE
D) Compiler error
Answer [=]
Answer[=]


 

15) What is the output of the below Java program with arrays?
public class Polo {
  public static void main(String args[])
  {
    String[] computer = {"RAM","HDD","MOUSE"};
    String[] parts = {computer[0],computer[2]};
    System.out.print(parts[1]);
  }
}
A) RAM
B) HDD
C) MOUSE
D) Compiler error
Answer [=]
Answer[=]
16) What is the output of the below Java program?
int ages[3] = {25, 27, 30};
System.out.println(ages[1]);
A) 25
B) 27
C) 30
D) Compile error
Answer [=]
Answer[=]
17) We should not specify the array size if declaration and initialization are done at the same time. (TRUE / FALSE)
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
18) If an index of an element is N, what is its actual position in the array?
A) N-1
B) N
C) N+1
D) N+2
Answer [=]
Answer[=]
19) An array in Java can be declared only of some predefined types. (TRUE/FALSE)
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
20) The name of an array variable or identifier can start with ___.
A) A letter
B) Underscore ( _ )
C) Dollar Symbol ($)
D) All
Answer [=]
Answer[=]
21) Shorthand array initialization in Java needs the keyword "new" to allocate memory to the array and elements. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]


 

22) Lazy initialization of array requires the keyword "new" to allocate memory to the array and its elements. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
23) What is the default value of an element of Object type array?
A) 0
B) null
C) -1
D) Garbage value
Answer [=]
Answer[=]
24) What is the default value of byte, short, int or long data type elements of an array in Java?
A) -1
B) 1
C) 0
D) Garbage value
Answer [=]
Answer[=]
25) What is the default value of float or double data type elements of an array in Java?
A) 0
B) 0.0
C) 1
D) 1.0
Answer [=]
Answer[=]
26) What is the default value of a char data type elements of an array in Java?
A) 'A'
B) '\0'
C) null
D) '\0' or null
Answer [=]
Answer[=]
27) What is the default value of boolean data type elements of an array in Java?
A) true
B) false
C) -
D) -
Answer [=]
Answer[=]
28) Allocating memory with the keyword "new" causes the array elements to carry default values. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
29) What is the output of the below Java program?
int balls[], rounds=3;
balls = new int[rounds];
for(int i=0; i<balls.length; i++)
    balls[i] = (i+1)*2;
for(int j=0; j<balls.length; j++)
    System.out.print(balls[j] + ",");
A) 0,2,4,
B) 1,2,3,
C) 2,4,6,
D) Compiler error
Answer [=]
Answer[=]
30) What is the output of the below Java program with arrays?
String[] ary = {"KITE", "AIR"};
String str = "PLANE";
ary[1] = str;
str = "FLY";
System.out.println(ary[1]);
A) AIR
B) PLANE
C) FLY
D) Compiler error
Answer [=]
Answer[=]
31) An array of arrays in Java is called ___ array.
A) Bidirectional
B) Combo
C) Multidimensional
D) Multi-value
Answer [=]
Answer[=]
32) A multidimensional array contains elements of the same data-type in all rows and columns. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
33) An array of dimension N contains __ number of subscripts or brackets?
A) N-1
B) N
C) N+1
D) 10*N
Answer [=]
Answer[=]
34) An array with two dimensions is called a two-dimensional array in Java. State TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
35) Row number and Column number in a Multidimensional array start with ___.
A) -1
B) 0
C) 1
D) 2
Answer [=]
Answer[=]
36) A 4-dimensional array is an array of ___ dimensional arrays.
A) 4
B) 3
C) 2
D) 1
Answer [=]
Answer[=]
37) Choose the correct way of initializing a multidimensional array below.
A)
int[][] code = {{1,2},{3,4,5}};
B)
int[2][] code = {{1,2},{3,4,5}};
C)
int[][] code={1,2,
              3,4,5};
D) All
Answer [=]
Answer[=]
38) What is the output of the Java program with the multidimensional array?
int[][] goats;
goats = new int[3][];
goats[0] = {1,2};
System.out.println(goats[0][1]);
A) 0
B) 1
C) 2
D) Compiler error
Answer [=]
Answer[=]
39) State TRUE or FALSE. In a multidimensional array, the number of Columns in each Row can be different.
1
2 3
4 5 6
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
40) While mentioning the array size in a multidimensional array using the new keyword, the left-most script is mandatory. State TRUE or FALSE.
int ary[][];
ary = new int[5][];//first dimension is compulsory.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.