Which of the following conditions is true only when the integer variables a , b
ID: 3704268 • Letter: W
Question
Which of the following conditions is true only when the integer variables a, b, and c contain three different values
a != b != c
Assuming that a user enters 25 as the value for x, what is the output of the following code snippet?
int x;
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
x = in.nextInt();
if (x < 100)
x = x + 5;
if (x < 500)
x = x - 2;
if (x > 10)
x++;
else
x--;
System.out.println(x);
(a != b) && (a != c) && (b != c)
What is the output of the code snippet given below?
for (int i = 0; i != 9; )
{
System.out.print (" " + i);
i = i + 2;
}
How many times does the following code snippet display "Loop Execution"?
for (int i = 0; i < 10; i++) ;
{
System.out.println("Loop Execution") ;
}
Ten times
What does the output show when this loop executes and finally terminates?
for ( int i = 20 ; i >= 2 ; i = i - 6 )
{
System.out.print ( i + ", " );
}
20, 14, 8, 2, –4
Which of the following for loops is not valid?
Which of the following for loops is not valid?
for (int i = 0; ; ) { . . . }
Given the following code snippet, what should we change to have all 26 alphabetic characters in the string str?
String str = "";
for ( char c = 'A' ; c < 'Z' ; c++ )
{
str = str + c;
}
Given the following code snippet, what should we change to have all 26 alphabetic characters in the string str?
String str = "";
for ( char c = 'A' ; c < 'Z' ; c++ )
{
str = str + c;
}
c <= 'Z'
Insert a statement that will correctly terminate this loop when the end of input is reached.
boolean done = false;
while (!done)
{
String input = in.next();
if (input.equalsIgnoreCase("Q"))
{
__________
}
else
{
double x = Double.parseDouble(input);
data.add(x);
}
}
done = false;
How many times will the output line be printed in the following code snippet?
for (int num2 = 1; num2 <= 3; num2++)
{
for (int num1 = 0; num1 <= 2; num1++)
{
System.out.println ( "" + num2 + " " + num1 );
}
}
Explanation / Answer
Question 1
Answer:
(a != b) || (a != c) || (b != c)
a != b != c
Question 2
Answer:
29
Question 3
Answer:
0 2 4 6 8 10 12 14 …. (infinite loop)
Question 4
Answer:
Ten times
Question 5
Answer:
20, 14, 8, 2
Question 6
Answer:
for (int i = 0) { . . . }
Question 7
Answer:
for (int i = 0) { . . . }
Question 8
Answer:
c <= 'Z'
Question 9
Answer:
c <= 'Z'
Question 10
Answer:
done = true;
Question 11
Answer:
9 times
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.