Java Reference
In-Depth Information
9.
Consider the method headings:
void
funcOne(
int
[] alpha,
int
size)
int
funcSum(
int
x,
int
y)
void
funcTwo(
int
[] alpha,
int
[] beta)
and the declarations:
int
[] list =
new int
[50];
int
[] AList =
new int
[60];
int
num;
Write Java statements that do the following:
a.
Call the method
funcOne
with the actual parameters,
list
and
50
,
respectively.
b.
Print the value returned by the method
funcSum
with the actual
parameters,
50
and the fourth element of
list
, respectively.
c.
Print the value returned by the method
funcSum
with the actual
parameters, the thirtieth and tenth elements of
list
, respectively.
d.
Call the method
funcTwo
with the actual parameters,
list
and
AList
,
respectively.
10.
Correct the following code so that it correctly initializes and outputs the
elements of the array
myList
:
Scanner console =
new
Scanner(System.in);
int
[] myList =
new
[10];
9
for
(
int
i = 1; i <= 10; i++)
myList = console.nextInt();
for
(
int
i = 1; i <= 10; i++)
System.out.print(myList[i] + " ");
System.out.println();
Suppose
list
is an array of six elements of type
int
. What is stored in
list
after the following Java code executes?
list[0] = 5;
11.
for
(
int
i = 1; i < 6; i++)
{
list[i] = i * i + 5;
if
(i > 2)
list[i] = 2 * list[i] - list[i - 1];
}
Search WWH ::
Custom Search