Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which of the following conditions is true only when the integer variables a , b , and c contain three different values (a != b)

Which of the following conditions is true only when the integer variables a, b, and c contain three different values

(a != b) || (a != c) || (b != c)
!((a == b) && (b == c) && (a == c))

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);

27
28
30
29

(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; }

No output
Invalid for statement
0 2 4 6 8
10 12 14 16 18 . (infinite loop)
0 2 4 6 8 10 12 14 . (infinite loop)

How many times does the following code snippet display "Loop Execution"?

for (int i = 0; i < 10; i++) ; { System.out.println("Loop Execution") ; }

None
One time
Infinite loop

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 + ", " ); }

14, 8, 2
20, 19, 18, 17, . . . 4, 3, 2
20, 14, 8, 2

20, 14, 8, 2, 4

Which of the following for loops is not valid?

for ( ; ; ) { . . . }
All are valid.
for (int i = 0, k = 1; ; i++) { . . . }
for (int i = 0) { . . . }
for (int i = 0; ; ) { . . . }

Which of the following for loops is not valid?

for ( ; ; ) { . . . }
All are valid.
for (int i = 0, k = 1; ; i++) { . . . }
for (int i = 0) { . . . }

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; }

int c = 'A'
str = c + str;
Must change to use a do ... while loop
c <= 'Z'

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; }

int c = 'A'
str = c + str;
Must change to use a do ... while loop

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 = 1;
exit;
done = true;
System.exit(0);
stop;

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 ); } }

12 times
6 times
3 times
9 times

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

In which type of climate is chemical weathering most effective?

Answered: 1 week ago

Question

=+1.2. Show that N and N are dense [A15] in (0, 1].

Answered: 1 week ago