Professional Documents
Culture Documents
03tracing Arrays Practice DaysOfWeek
03tracing Arrays Practice DaysOfWeek
03tracing Arrays Practice DaysOfWeek
Date: __________
Days of the Week – Basic Arrays
1. Look at the following program.
d. What is DaysOfWeek.length?
i. DaysOfWeek[1].equals(“Sunday”)
ii. DaysOfWeek[7].equals(“Saturday”)
iii. DaysOfWeek.length==6
iv. DaysOfWeek[0]== “Sunday”
v. WeekDays[3].equals(“Tuesday”)
(b) Correct each declaration and construction so that the code runs.
3. Trace what is happening in the following array, using the tables provided.
int s = 2;
int a [] = {-1, -3, 5, 31, 0, 7};
[0] [1] [2] [3] [4] [5]
a [4] =2;
[0] [1] [2] [3] [4] [5]
a [5] = 88;
[0] [1] [2] [3] [4] [5]
a [s] --;
[0] [1] [2] [3] [4] [5]
a [0] = a [3];
[0] [1] [2] [3] [4] [5]
a[3] = s + 2;
[0] [1] [2] [3] [4] [5]
a[1] ++;
[0] [1] [2] [3] [4] [5]