Java OCA OCP Practice Question 1079

Question

Which of the following types is objects not allowed to be in order for this code to compile?

for (Object obj : objects) { 
} 
  • A. ArrayList<Integer>
  • B. int[]
  • C. StringBuilder
  • D. All of these are allowed.


C.

Note

A for-each loop is allowed to be used with arrays and ArrayList objects.

StringBuilder is not an allowed type for this loop, so Option C is the answer.




PreviousNext

Related