Question

Which for loop is implemented correctly in Java? Group of answer choices for (i = 0...

Which for loop is implemented correctly in Java?

Group of answer choices

for (i = 0 ; i < 10) {

for (i < 10 ; i++) {

for (i = 0 ; i < 10 ; i++) {

for (i = 0 ; i++ ; i < 10) {

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: Options c) for (i = 0 ; i < 10 ; i++) {

Explanation:

Option a)

Program:

public class MyClass { // Here taking class name as MyClass
public static void main(String args[]) { // Start of main()
int i;
for (i = 0 ; i < 10) { // Loop Iteration
System.out.println("Hai ");
}
}// End of main()
}// End of MyClass

Output: // Produce following Error

Option b)

Program:

public class MyClass { // Here taking class name as MyClass
public static void main(String args[]) { // Start of main()
int i;
for (i < 10 ; i++) { // Loop Iteration
System.out.println("Hai ");
}
}// End of main()
}// End of MyClass

Output: // Produce following Error

Option c)

Program:

public class MyClass { // Here taking class name as MyClass
public static void main(String args[]) { // Start of main()
int i;
for (i = 0 ; i < 10 ; i++) { // Loop Iteration
System.out.println("Hai ");
}
}// End of main()
}// End of MyClass

Output:

Option d)

Program:

public class MyClass { // Here taking class name as MyClass
public static void main(String args[]) { // Start of main()
int i;
for (i = 0 ; i++ ; i < 10) { // Loop Iteration
System.out.println("Hai ");
}
}// End of main()
}// End of MyClass

Output: // Produce following Error

Add a comment
Know the answer?
Add Answer to:
Which for loop is implemented correctly in Java? Group of answer choices for (i = 0...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT