Question: For Java questions, I need help figuring out a few questions: (1) The indices of an array always start with position number 0 . (a)

For Java questions, I need help figuring out a few questions:

(1) The indices of an array always start with position number 0 . (a) True (b) False

(2) What is the output of the following program segment?

int[] b1 = {5, 10, 15};

System.out.println("\t" + b1[1]);

(a) 0 (b) 1 (c) 10 (d) 2 (e) 5

(3) What is the output of the following program segment?

int[] b1 = { 5, 10, 15 };

System.out.println("\t" + b1[2]);

(a) 0 (b) 1 (c) 5 (d) 10 (e) 15

(4) After the this code segment is executed, what will be the final value of the variable sum?

int[] arrayA = { 5, 10, 15, 20, 25 };

int sum = 1 ;

for (int i = 0; i < 5; i++)

sum = sum + arrayA[i];

System.out.println("\t" + sum);

(a) 80 (b) 76 (c) 75 (d) 85 (e) 90

(5) What is the range of valid indices for the following? int[] w = new int[101];

(a) 0 - 100 (b) 1 - 101

(c) To infinity and beyond infinity (d) None of these

int[] num = new int[100];

for(int i = 0; i < 50; i++)

num[i] = i;

num[5] = 10;

num[55] = 100;

(1) What is the data type of the array above?

(a) int (b) list

(c) char (d) num

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!