Quiz4.fa10

Quiz4.fa10 - SoundSample foo = noise.getSamples(); A)...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Signature _____________________ CSE 8A Name ________________________ Quiz 4 cs8f ____ Fall 2010 Student ID ____________________ This quiz is to be taken by yourself with closed books, closed notes, no electronic devices. What will be output from the following code: int x = 2; int y = 0; while ( x < 10 && y <= 1 ) { x++; y++; System.out.println( x + " " + y ); } System.out.println( x + " " + y ); What will be output from the following code: int x = 4; int y = 2; while ( x < 7 || y <= 3 ) { System.out.println( x + " " + y ); x++; y++; } System.out.println( x + " " + y ); Write the equivalent statement using the other variable for each statement (A and B) below. In A) write the equivalent statement using foo , in B) write the equivalent statement using noise . Assume the following declarations: Sound noise = new Sound( FileChooser.pickAFile() );
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: SoundSample foo = noise.getSamples(); A) noise.getSampleValueAt( i ); B) foo[42].setValue( 3700 ); Which of the following loops will NOT cause an ArrayIndexOutOfBounds exception? Circle all the correct answers. There may be more than one correct answer. [Correct +1; Incorrect: -1; No negative score] A) for ( int i = 0; i &lt;= this.getWidth(); i++ ) B) for ( int i = this.getWidth(); i &gt; 0; i-- ) C) for ( int i = this.getWidth() 1; i &gt;= 0; i-- ) D) for ( int i = 16; i &lt; this.getWidth(); i++ ) E) for ( int i = this.getWidth() 16; i &gt; 0; i-- ) F) for ( int i = -1; i &lt; this.getWidth(); i++ ) Put your answer here: ______ What is printed if the line if ( foo &lt; a ) was changed to if ( foo &lt;= a ) ? ______ What is printed if the line if ( foo &lt; a ) was changed to if ( foo &gt; a ) ? ______...
View Full Document

This note was uploaded on 08/31/2011 for the course CSE 8a taught by Professor Kube,p during the Fall '08 term at UCSD.

Page1 / 2

Quiz4.fa10 - SoundSample foo = noise.getSamples(); A)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online