{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Quiz4.fa10

Quiz4.fa10 - SoundSample foo = noise.getSamples A...

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

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() );

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

View Full Document
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 <= this.getWidth(); i++ ) B) for ( int i = this.getWidth(); i > 0; i-- ) C) for ( int i = this.getWidth() – 1; i >= 0; i-- ) D) for ( int i = 16; i < this.getWidth(); i++ ) E) for ( int i = this.getWidth() – 16; i > 0; i-- ) F) for ( int i = -1; i < this.getWidth(); i++ ) Put your answer here: ______ What is printed if the line if ( foo < a ) was changed to if ( foo <= a ) ? ______ What is printed if the line if ( foo < a ) was changed to if ( foo > a ) ? ______...
View Full Document

{[ snackBarMessage ]}

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
Ask a homework question - tutors are online