Java Reference
In-Depth Information
System.out.println();
a.
What is the final value of
s
?
none of these
11
ii.
4
iii.
26
iv.
i.
If a semicolon is inserted after the right parenthesis in the
for
loop
control expressions, what is the final value of
s
?
b.
5
v.
none of these
0
ii.
1
iii.
2
iv.
i.
If the
5
is replaced with a
0
in the
for
loop control expression, what is
the final value of
s
?
c.
none of these
0
ii.
1
iii.
2
iv.
i.
State what output, if any, results in each of the following statements:
23.
for
(i = 1; i <= 1; i++)
System.out.print("*");
a.
System.out.println();
for
(i = 2; i >= 1; i++)
System.out.print("*");
b.
System.out.println();
for
(i = 1; i <= 1; i--)
System.out.print("*");
c.
System.out.println();
for
(i = 12; i >= 9; i--)
System.out.print("*");
System.out.println();
d.
for
(i = 0; i <= 5; i++)
System.out.print("*");
e.
System.out.println();
for
(i = 1; i <= 5; i++)
{
f.
System.out.print("*");
i = i + 1;
}
System.out.println();
24.
Write a
for
statement to add all multiples of 3 between 1 and 100.
25.
What is the output of the following code? Is there a relationship between
the variables
x
and
y
? If yes, state the relationship? What is the output?
Search WWH ::
Custom Search