
23-for-each loop + java
Authored by ANIL KUMAR
English
Professional Development
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
32 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What is for loop and forEach loop?
for loop is used only for arrays, while forEach loop can be used for any collection
for loop can only iterate forward, while forEach loop can iterate forward and backward
for loop requires an index variable, while forEach loop does not
for loop is faster than forEach loop
2.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What is forEach loop in Java explain with example?
for (int i = 0; i < arr.length; i++) {System.out.println(arr[i]);}
for (String str : list) {System.out.println(str);}
while (iterator.hasNext()) {System.out.println(iterator.next());}
do {System.out.println(str);} while (str != null);
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Is forEach loop only for arrays?
Yes
No
4.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What can forEach loops not do?
Modify the collection being iterated
Iterate through multiple collections at once
Break out of the loop early
None of the above
5.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Is for loop same as forEach?
Yes
No
6.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Is forEach faster than for Java?
Yes
No
7.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What is for-each loop write the syntax of it?
for(i=0;i<arr.length;i++)
for(Object obj: arr)
for(i in arr)
for each(obj in arr)
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?