CS 111 - 4/30/15 Final Wednesday: 5/6/14 from 10:30am to 12:30pm in LC - F1 20 Multiple Choice Questions 2 Write Method Questions No Picture or Turtle questions Questions on Sound will exists Questions on Arrays will exist (similar to Lab Quiz questions) What are the values in the array when this code finishes executing? int array[] = new int [10]; int x = 0; for ( int i = 0 ; i < array.length ; i++ ) array [i] = i; for ( int i = 0 ; i < array.length - 3 ; i = i + 3 ) { x = array[i] + array[i+1] + array[i+ 2]; array [i] = x; } pos: 0 1 2 3 4 5 6 7 8 9 a 0 1 2 3 4 5 6 7 8 9 b 3 1 2 12 4 5 21 7 8 9 c 3 6 9 12 15 18 21 28 32 45 d 3 6 9 12 15 18 21 28 8 9 e None of the above. Answer is B public static void m1 ( ) { for ( ) { int x; x = .... ; } System.out.println( x ); // x is unknown } public static void m1 ( ) { int x = 0; // x is declared outside of the for loop for ( ) { x = .... ; } System.out.println( x ); // x is known } % - modulus operator remainder from an integer division x = 75 % 8 ; // x will get the value of 3 9 R 3 --------- 8 | 75 - 72 ------ 3 Determine if a number is odd or even if ( x % 2 == 0 ) { // x is even } else { // x is odd } Which index of a background sound should be combined with the current index of a foreground sound 1 1 1 1 1 1 1 1 1 1 2 2 2 2 Foreground: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 ... Background: 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 bgIndex = fgIndex % bgLength I need to separate an integer value into its various digits: 34657 onesDigit = x % 10; ----------------------------- int array[] = new int [6]; int z = 9; for ( int i = 0 ; i < array.length ; i++ ) { array [i] = z * i; } for ( int i = 0 ; i < array.length ; i = i + (i + 2) ) { z = z + (array[i] * 2); } Pos: 0 1 2 3 4 5 Val: 0 9 18 27 36 45 z: 9 45 i: 0 2 6 --------------------------- int x; int y = 10; int z = 1; for ( x=0 ; x