Home Computer Science Iterative Statements – Java MCQ Quiz

Iterative Statements – Java MCQ Quiz

This Java Quiz is based on Iterative Statements in Java MCQs. You can also attempt the previous Operators in Java MCQ Quiz or Next Loops in Java MCQ Quiz

726

Iterative Statements - Java MCQ Quiz

Java’s iteration statements are for, while, and do-while. These statements create what we commonly call loops. As you probably know, a loop repeatedly executes the same set of instructions until a termination condition is met. Java has a loop to fit any programming need.

while:

The while loop is Java’s most fundamental loop statement. It repeats a statement or block while its controlling expression is true. Here is its general form:

while(condition) {

// body of the loop

}

do-while:

If the conditional expression controlling a while loop is initially false, then the body of the loop will not be executed at all. However, sometimes it is desirable to execute the body of a loop at least once, even if the conditional expression is false to begin with. In other words, there are times when you would like to test the termination expression at the end of the loop rather than at the beginning. Fortunately, Java supplies a loop that does just that: the do-while. The do-while loop always executes its body at least once, because its conditional expression is at the bottom of the loop. Its general form is:

do {

// body of the loop

} while (condition);

for:

There are two forms of the for loop. The first is the traditional form that has been in use since the original version of Java. The second is the new “for-each” form.

Here is the general form of the traditional for statement:

for(initialization; condition; iteration) {

// body

}

The general form of the for-each version of the for is shown here:

for(type itr-var : collection) statement-block

Quiz Description: 

Name: Iteration -Java MCQ quiz

Subject:  Java

Topic: Introduction

Questions: 15 Objective Type Questions

Time Allowed: 15 Minutes

Language: English

Important for:  B. Tech. / M. Tech. Students, B.Sc. / M.Sc. (CS / IT) and aspirants of I.E.S. and other competitive exams, computer science job interviews, Java job interviews, etc.

Created By: Esha Tripathi

Previous QuizOperators – Java MCQ Quiz
Next QuizLoops in Java – MCQ Quiz

LEAVE A REPLY

Please enter your comment!
Please enter your name here