Java Reference
In-Depth Information
4.
What is the output of the following Java code?
num = 1;
while
(num < 10)
{
System.out.print(num + " ");
num = num + 2;
}
System.out.println();
5.
When does the following
while
loop terminate?
ch = 'D';
5
while
('A' <= ch && ch <= 'Z')
ch = (
char
)((
int
)(ch) + 1));
Suppose that the input is:
38 35 71 14 -1
What is the output of the following code? Assume all variables are properly
declared.
sum = console.nextInt();
num = console.nextInt();
6.
for
(j = 1; j <= 3; j++)
{
num = console.nextInt();
sum = sum + num;
}
System.out.println("Sum = " + sum);
Suppose that the input is:
38 35 71 14 -1
What is the output of the following code? Assume all variables are properly
declared.
sum = console.nextInt();
num = console.nextInt();
7.
while
(num != -1)
{
sum = sum + num;
num = console.nextInt();
}
System.out.println("Sum = " + sum);
Search WWH ::
Custom Search