Multiple choice technology programming languages

  1. class Loopy { 2. public static void main(String[] args) { 3. int[] x = {7,6,5,4,3,2,1}; 4. // insert code here 5. System.out.print(y + " "); 6. } 7. } }

  1. for(int y : x) {

  2. for(x : int y) {

  3. int y = 0; for(y : x) {

  4. for(int y=0, z=0; z<x.length; z++) { y = x[z];

  5. for(int y=0, int z=0; z<x.length; z++) { y = x[z];

  6. int y = 0; for(int z=0; z<x.length; z++) { y = x[z];

Reveal answer Fill a bubble to check yourself
A,D,F Correct answer
Explanation

A is correct for-each syntax. D is valid - declares y=0, z=0 then iterates. F is valid - y declared outside, z declared in loop. B has wrong order. C declares y in initialization which isn't allowed. E incorrectly declares int z in initialization.