0% found this document useful (0 votes)
7 views2 pages

Class X Arrays

The document contains a series of questions related to arrays in Java, including accessing elements, declaring arrays, and understanding array properties. It also includes programming tasks such as creating and manipulating multi-dimensional arrays and sorting arrays. Each question is designed to test knowledge of Java array syntax and functionality.

Uploaded by

sumanpratham5555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Class X Arrays

The document contains a series of questions related to arrays in Java, including accessing elements, declaring arrays, and understanding array properties. It also includes programming tasks such as creating and manipulating multi-dimensional arrays and sorting arrays. Each question is designed to test knowledge of Java array syntax and functionality.

Uploaded by

sumanpratham5555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Chapter-Arrays

CMS, IndiraNagar, Campus, Lucknow

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.4 What is the size in bytes of the following array


char ch[]={‘a’, ‘e’, ‘I’ , ‘O’, ‘U’}
a) 5 bytes b) 10 bytes c) 15 bytes d) 20 bytes

Q.5 For the code : int arr [ ] [ ] = { {1,2,3} , {4,5,6} , {7,8,9} };


System.out.println( arr [2][1] * arr [1,2] );
What is the output ?
a) 8 b) 15 c) 35 d) 48

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.7 What will be the output of the following code


int arr[]={0,5,10,15,20};
System.out.println(Math.pow(arr[2],arr[0]*arr[1]));

Q.8 What will be the output of the following code


String str [ ] ={“red”, “green”, “pink”, “purple” , “orange”};
System.out.println(str[3].length() * str[2].lastIndexOf(‘p’));
System.out.println(str.length);

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.

You might also like