Question: I need some help with answering some questions for Java Programing: (1) Which of the following declares an array of int named hits? (a) int

I need some help with answering some questions for Java Programing:

(1) Which of the following declares an array of int named hits?

(a) int hits; (b) new int hits[];

(c) int[] hits; (d) int hits = int[]

int[] array1 = { 1, 3, 5, 7 }

for(int i = 0; i < array.length; i++) {

if(array1[i] > 5)

System.out.println(i + " " + array1[i]);

}

(2) Which indices are in bounds for the array array1, given the declaration above?

(a) 0 , 1 , 2 , 3 (b) 1 , 3 , 5 , 7

(c) 1 , 2 , 3 , 4 (d) 0 , 1 , 3 , 5

(3) What is the output of the code fragment above?

(a) 0 3 (b) 7 3

(c) 3 7 (d) 5 1

int[] x = new int[10];

x[0] = 34;

x[1] = 88;

System.out.println(x[0] + " " + x[1] + " " + x[10]);

(4) What is the output of the code fragment above?

(a) 34 88 0 (b) 0 34 88

(c) 34 88 88 (d) This program throws an exception.

(5) A " matrix " is a two - dimensional array.

(a) True (b) False

(6) The following declaration int[ ][ ] senators = new int[50][2]; is an example of a " multidimensional array. "

(a) True (b) False

(7) Given an array score[x] " x " can be referred to as either the " index " or " subscript " of the array.

(a) True (b) False

(8) The following is a legal array declaration: int[ ] intArray = new int[ ];

(a) True (b) False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!