wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Array

Total questions: 11

Worksheet time: 11mins

Name
Class
Date
1.

Java code to create a non-element array of student marks with the size of 20.

a)

double mark;

b)

double [20] mark = new double;

c)

double [ ] mark = new mark [20];

d)

double [ ] mark = new double [20];

2.

Java code to create a non-element array of student name with size 15.

a)

String [ ] name = new String;

b)

String [ ] name = new String [15];

c)

name = new String [15];

d)

String [15] name = new String [ ];

3.

Java code to create an array of student id with element 115331, 450055, 555641, 875560 and 987555.

a)

int [ ] id = new {115331, 450055, 555641, 875560, 987555};

b)

int [5] id = {115331, 450055, 555641, 875560, 987555};

c)

int [ ] id = {115331, 450055, 555641, 875560, 987555};

d)

int [ ] id = new int [5];

4.

Java code to create an array of subject code with element S, M, C, P, I and K.

a)

char [ ] code = {'S', 'M', 'C', 'P', 'I' and 'K'};

b)

char [ ] code = {S, M, C, P, I, K};

c)

char [ ] code = {"S", "M", "C", "P", "I", "K"};

d)

char [ ] code = {'S', 'M', 'C', 'P', 'I', 'K'};

5.

Java code to display the size of an array name studentname[ ].

a)

System.out.println("The size is " + studentname[ index ]);

b)

System.out.println("The size is " + studentname.length);

c)

System.out.println("The size is " + length.length);

d)

System.out.println("The size is " + studentname);

6.

Java code to display all elements of array studentname[ ].

a)
b)
c)
d)
7.

Java code to read elements into array studentname[ ].

a)
b)
c)
d)
8.

Java code to read elements into array customerid[ ].

a)
b)
c)
d)

None of the above is the right answer.

9.

A code segment to identify the largest element in an array.

a)
b)
c)
d)
10.

Based on the code segment below:- identify the name of the array.


for(int j=0; j<balance.length; j++)

{

System.out.print("Enter amount: ");

.......

}

a)

No answer.

b)

temp[ ]

c)

balance

d)

balance [ i ]

11.

Based on the code segment below:- identify the name of the array.


for(int j=0; j<balance.length; j++)

{

System.out.print("Enter amount: ");

.......

}

a)

No answer.

b)

temp[ ]

c)

balance

d)

balance [ i ]