Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

part 1-How many iterations will the following loop generate: for (int i = 0; i < 10; i++) { System.out.println( i is + i

part 1-How many iterations will the following loop generate:

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

Infinite number of times.

0 (zero)

1

10

part 2-Consider the following two code snippets (A and B):

A:

public static void main(String[] args ) { int i = 0; for (i = 0; i < 10; i++) { System.out.println( "i is " + i ); } }

B:

public static void main(String[] args ) { for (int i = 0; i < 10; i++) { System.out.println( "i is " + i ); } }

In which snippet, A or B, variable i has a greater ("wider") scope?

Variable i has no scope.

A

Same scope in both A and B.

B

part 3 With a post-test loop (do-while) you could end up with ZERO iterations (loop body statements will never get executed)?

Yes

No

part 4. When using an if/else if structure, it is mandatory to have an else block. Yes or no?

Yes

No

part 5. An else block is mandatory after an if. Yes or no?

Yes

No

QUESTION 6. When using an if/else if structure, we can only use one else if block. Yes or no?

Yes

No

QUESTION 7. What is the output of the following code?

int age = 30; if ( age > 33 ) System.out.print( 1 ); else System.out.print( 2 ); System.out.println( 3 );

Pay attention to syntax and the difference between print() and println() methods.

1

23

2

12

QUESTION 8.Is this if statement:

if (j >= 0 && (j < 10 || j >= 10))

equivalent to:

if (j >= 0)

?

Yes

No

QUESTION 9. How many iterations will the following for loop generate?

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

10

Infinite number of times.

9

0 (zero)

QUESTION 10. Which of the following expresses the condition a is less than b and c. in Java?

a < b && c

a < b && a < c

a < b || a < c

a < b < c

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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Describe and compare types of usability testing

Answered: 1 week ago