Which two code fragments, inserted independently at line 12, will allow the class to compile?

Given:
10. public class Bar {
11. static void foo( int… x ) {
12. // insert code here
13. }
14. }
Which two code fragments, inserted independently at line 12, will allow the class to compile?
(Choose two.)

Given:
10. public class Bar {
11. static void foo( int… x ) {
12. // insert code here
13. }
14. }
Which two code fragments, inserted independently at line 12, will allow the class to compile?
(Choose two.)

A.
while( x.hasNext() ) System.out.println( x.next() );

B.
foreach( x ) System.out.println(z);

C.
for( int i=0; i< x.length; i++ ) System.out.println(x[i]);

D.
for( int z : x ) System.out.println(z);



Leave a Reply 0

Your email address will not be published. Required fields are marked *