Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What does the following code print? for (int i = 3; i

What does the following code print? for (int i = 3; i <= 12; i++) { System.out.print(i + " "); } 3 4 5 6 7 8 9 10 11 12 3 5 7 9 11 4 5 6 7 8 9 10 11 12 5 6 7 8 9 2 1 ? How many times does the following method print a *? for (int i = 3; i <= 9; i++) { System.out.print("*"); } 7 6 10 9 3 1 ? What does the following code print? int x = -5; while (x < 0) { x++; System.out.print(x + " "); } 5 4 3 2 1 -4 -3 -2 -1 0 -5 -4 -3 -2 -1 4 1 ? How many stars are output when the following code is executed? for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) System.out.println("*"); } 15 50 25 5 10 5 1 ? What is printed as a result of the following code segment? for (int k = 0; k < 20; k+=2) { if (k % 3 == 1) System.out.println(k + " "); } 4 10 16 4 16 0 6 12 18 0 2 4 6 8 10 12 14 16 18 1 4 7 10 13 16 19 6 1 ? What are the values of var1 and var2 after the following code segment is executed and the while loop finishes? int var1 = 0; int var2 = 2; while ((var2 != 0) && ((var1 / var2) >= 0)) { var1 = var1 + 1; var2 = var2 - 1; } var1 = 1, var2 = 1 var1 = 0, var2 = 2 var1 = 3, var2 = -1 var1 = 2, var2 = 0 The loop won't finish executing because of a division by zero

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

Students also viewed these Databases questions

Question

=+Is the humor appropriate for the organization?

Answered: 1 week ago