Array MCQ Questions and Answers

Home | Java | Array

Java Array MCQ Questions and Answers: Here learn quiz questions on Java Array and download pdf of 50 most important objective questions for all competitive exam.

Page: 1/2

1) In Java arrays are

2) Which one of the following is a valid statement?

3) What is the result of compiling and running the following code?

public class Test
{
public static void main(String[] args)
{
int[] a = new int[0];
System.out.print(a.length);
}
}

4) What will be the output?

public class Test
{
public static void main(String[] args)
{
int[] x = new int[3];
System.out.println("x[0] is " + x[0]);
}
}

5) Which of these operators is used to allocate memory to array variable in Java?

6) Which of these is an incorrect array declaration?

7) Which of these is an incorrect Statement?

8) Which of these is necessary to specify at time of array initialization?

9) What is the output of this program?

class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}

10) What is the output of this program?
class evaluate
{
public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);
}
}