Log in
Sign up for FREE
arrow_back
Library
Semester Final CS3 (1/11/2024)
By Mickey Arnold
star
star
star
star
star
Share
share
Last updated almost 2 years ago
16 questions
Add this activity
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 1
1.
What is output by the code below?
String[] ray;
ray = new String[4];
System.out.println( ray[0] );
one
two
null
three
0
Question 2
2.
What is output by the code below?
Integer[] ray;
ray = new Integer[4];
System.out.println( ray[3] );
2
3
0
null
1
Question 3
3.
What is output by the code below?
Integer[] ray;
ray = new Integer[4];
ray[1] = null;
ray[0] = new Integer(3);
ray[2] = new Integer(99);
System.out.println( ray[2] );
4
0
null
3
99
Question 4
4.
What is output by the code below?
Integer[] ray = {11,55,-4,909};
System.out.println( ray[3] );
0
11
-4
55
909
Question 5
5.
What is output by the code below?
Double[] ray = {11.2,55.0,-4.5,909.0};
System.out.println( ray[1] );
55.0
909.0
-4.5
11.2
0
Question 6
6.
What is output by the code below?
Double[] ray = {11.2,7.2,-4.5,909.0};
ray[1] = new Double(55.0);
System.out.println( ray[1] );
-4.5
11.2
55.0
909.0
0
Question 7
7.
What is output by the code below?
Double[] ray = {3.2,5.7,6.3,1.9};
double x = 0;
for( double r : ray )
x += r;
System.out.println( x );
17.1
17.2
16.4
17.4
16.8
Question 8
8.
What is output by the code below?
Double[] ray = {3.1,5.2,6.3,1.4};
for( double r : ray )
r = 0;
System.out.println( ray[2] );
0.0
3.1
6.3
5.2
1.4
Question 9
9.
What is output by the code below?
String[] ray;
ray = new String[4];
ray[1] = "one";
System.out.println( ray[1] );
0
null
one
three
two
Question 10
10.
What is output by the code below?
String[] ray;
ray = new String[4];
ray[1] = "one";
ray[2] = "two";
ray[3] = "three";
System.out.println( ray[0] );
one
0
two
null
three
Question 11
11.
What do you call the condition that stops recursion?
base case
return
break
shut it down
stop
Question 12
12.
What is returned the call
fun(6) ?
public static int fun(int x)
{
if(x < 1)
return 1;
else
return x + fun(x - 1);
}
22
29
37
16
11
Question 13
13.
What is returned by the call
fun(8) ?
public static int fun(int x)
{
if(x < 1)
return 1;
else
return x + fun(x - 1);
}
16
22
11
37
29
Question 14
14.
What is returned by the call
fun(8) ?
public static int fun(int x){
if(x < 1)
return 1;
else
return x + fun(x - 2);
}
21
17
31
26
13
Question 15
15.
What is returned by the call
fun(6) ?
public static int fun(int x){
if(x < 1)
return 1;
else
return x + fun(x - 2);
}
21
31
13
26
17
Question 16
16.
What is returned by the call
fun(10) ?
public static int fun(int x)
{
if (x < 1)
return x;
else
return x + fun(x - 2);
}
20
30
0
8
12