Class X Arrays
Class X Arrays
Q.1. Which of the following is the correct way to access the last element of the array
named arr.
a) arr[arr.length()-1]
b) arr[arr.length-1]
c) arr[arr.size()-1]
d) arr[arr.size-1]
Q.2 Write the Java statement to declare an array named weight of type double and
size 10.
a) double weight[10]=new Double[];
b) double weight[]=new Double[10];
( c ) double weight[10]=new double[];
d) double weight[]=new double[10];
Q.3 The values of the single dimensional array can be either row wise or column wise.
(a) True
(b) False
Q.6 From the following code what will be the value of i and m.
int arr[]={1,2,5,10,15};
int i=++arr[1];
System.out.println(i);
int m=arr[i++];
System.out.println(m);
Q.9 Write a program in Java to create a double dimensional array of size [3x3] and
print the values of left and right diagonal.
For eg:
Input: 1 2 3
4 5 6
7 8 9
Output:
Left diagonal:
1
5
9
Right diagonal
3
5
7
Q.10 WAP in Java to create an array of ten names and arrange it in descending order
using Bubble Sort.