Java Assignment

profilejpFlute
java_questions.docx

Complete all problems

1, 3, 7, 10, 15, 17, 21, 35

1.   What are the valid ways to declare an integer array named a? (Check all that apply.)

imgint [ ] a;

imgint a [ ] ;

imgarray int a;

int array a;

3.   An array a has 30 elements; what is the index of its last element?

img29

img30

img31

  7.   How do you retrieve the number of elements in an array a?

imga.length ( )

imga.length

imga.size ( )

imga.size

10.   Aggregate comparison of arrays is possible in Java.

imgtrue

imgfalse

15.   What is the output of this code sequence?

img

17.   What is the output of this code sequence?

img

21.   What is the output of this code sequence?

img

35. Outline and discuss how to declare, instantiate and access array elements in shortest amount of code. Include your assessment on the pros and cons of this method.

Complete all problems

1, 3, 7, 10, 15, 17,

21

, 35

1.

What are the valid ways to declare an integer array named

a

? (Check all that apply.)

int [

] a;

int a [

]

;

array int a;

int array a;

3.

An array

a

has

30 elements; what is the index of its last element?

29

30

31

7.

How do you retrieve the number of elements in an array

a

?

a.length

(

)

a.length

a.size

(

)

a.size

10.

Aggregate comparison of arrays is possible in Java.

true

false

15.

What

is the output of this code sequence?

17.

What is the output of this code sequence?

21.

What is the output of this code sequence?

Complete all problems

1, 3, 7, 10, 15, 17, 21, 35

1. What are the valid ways to declare an integer array named a? (Check all that apply.)

int [ ] a;

int a [ ] ;

array int a;

int array a;

3. An array a has 30 elements; what is the index of its last element?

29

30

31

7. How do you retrieve the number of elements in an array a?

a.length ( )

a.length

a.size ( )

a.size

10. Aggregate comparison of arrays is possible in Java.

true

false

15. What is the output of this code sequence?

17. What is the output of this code sequence?

21. What is the output of this code sequence?