Skip to main content\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 10.2 Arrays-WE1-P1
Subgoals for Evaluating Arrays.
Set up array from 0 to size-1
Evaluate data type of statements against array
-
Trace statements, updating slots as you go
Remember assignment subgoals
Subsection 10.2.1
Exercises Exercises
1.
2.
Q2: Assume the following declarations:
int [] beta;
beta = new int[3];
Evaluate these statements:
beta[1] = 22;
beta[0] = beta[1] - 11;
beta[2] = beta[0] + beta[1];
Give the contents of array beta
after the execution of the above statements:
beta[0] = “”
beta[1] = “”
beta[2] = “”
3.
Q3: Which line produces the first compiler error?
double [] gamma = new double[5];
gamma[0] = 14;
gamma[1] = gamma[0];
gamma[gamma[0]] = 42;
gamma[5] = 22;
You have attempted
of
activities on this page.