22 questions
What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };
1
5
6
12
Which of the following is FALSE about arrays on Java
A java array is always an object
Length of array can be changed after creation of array
Arrays in Java are always allocated on heap
class Demo1
{
public static void main(String args[])
{
int i[] = new int[10];
System.out.println(i[10]);
}
}
0
Garbage Value
Out-of-bounds exception
Error
ar
, given the following declaration:int[] ar = {2, 4, 6, 8 }
0, 1, 2, 3
1, 2, 3, 4
0, 2, 4, 6
What is the first index of an array?
1
0
2
3
For the array:
int stats[3];
What is the range of the index?
0 to 3
0 to 2
1 to 3
0 to 4
int [] nums = {2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums?
nums[4]
nums[3]
nums(4)
nums(3)
What is the error in the following code fragment?
double [] average = new double [20];
average[20] = 15.25;
A cast is required
data not initialized
A two-dimensional array is required
Array Out-of-bounds error
class Test{
public static void main (String[] args) {
int [] arr1= {1, 2, 3};
int [] arr2 = {1, 2, 3};
if(arr1[0] == arr2[0])
System.out.println("Same");
else
System.out.println("Not same");
}}
Same
Not same
Error
When you declare an array name, no computer memory address is assigned to it. Instead, the array variable name has the special value ____.
Empty
Null
False
Zero