Write a for-each loop that prints all elements in a collection of Student objects called role. What is required for that loop to work?

What will be an ideal response?


```
for (Student pupil : role)
System.out.println(pupil);
```
For this code to work, the class that defines the object referenced by role must implement the Iterable interface.

Computer Science & Information Technology

You might also like to view...

Two components that have a name property are __________ and __________.

Fill in the blank(s) with correct word

Computer Science & Information Technology

To determine whether two reference variables of the Integer type point to the same Integer object, we can use either the method equals of the class Integer or the operator ==.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A control's ____ event occurs when a change is made to the contents of a control's Text property.

A. CodeChanged B. TextChanged C. ChangedText D. TextModified

Computer Science & Information Technology

Most portable devices use a special _______________ key that enable some keys to perform an extra duty.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology