Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Lecture 4.4 Part 2

Total questions: 11

Worksheet time: 7mins

Name
Class
Date
1.

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];

2.

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);

3.

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

a)
b)
c)
d)
4.

Java code to read elements into array studentname[ ].

a)
b)
c)
d)
5.

Java code to read elements into array customerid[ ].

a)
b)
c)
d)

None of the above is the right answer.

6.

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

a)
b)
c)
d)
7.

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 ]

8.
Which of the following statements outputs the fifth value in the quizzes array?
a)
System.out.println(quizzes[5]);
b)
quizzes[4];
c)
quizzes[5];
d)
System.out.println(quizzes[4]);
9.

What is returned by values[5]?

a)

2

b)

12

c)

6

d)

8

10.

var nums =[2, 3, 5, 8, 9, 11];

How would you access the first element in nums

a)

num(1);

b)

num[1];

c)

num(0);

d)

num[0];

11.

what is the result of :

nums[1]+nums[3]

a)

3

b)

14

c)

6

d)

5