Single Choice
Moderate
Q1. What is the correct syntax for a for loop in Java?
ID: #23071
For Loop in Programming Language
99 views
Question Info
#23071Q ID
ModerateDifficulty
For Loop in Programming LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
In Java, the correct syntax of a for loop includes three parts inside the parentheses, separated by semicolons. The first part is the initialization (int i = 0), the second part is the condition check (i < 10), and the third part is the increment (i++). The loop will continue executing until the condition becomes false. Option A is incorrect because commas are used instead of semicolons. Option C uses colons instead of semicolons, which is not valid in Java. Option D is the syntax for Python, not Java.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic