Reading Quiz Questions Week 8
These are the questions that will appear on the reading quizzes in week 8. Remember these quizzes take place at the start of class, and you get points for correctness, not just participation. These will be the exact questions we ask you. They will be multiple choice clicker questions, but we do not provide the answer choice here. If you can answer them without the answer choices, you'll have no problems answering them when you see the choices. These are not designed to be overly tricky.
Monday February 25th
/**Method to copy part of the passed sound into this sound at the given start index
* @param source the souce sound to copy from
* @param sourceStart the starting index to copy from in the source (the copy will include this)
* @param sourceStop the ending index (the copy won’t include this)
* @param targetStart the index to start copying into
public void splice (Sound, source, int souceStart, int sourceStop, int targetStart)
{
//loop copying from source to target
for(int sourceIndex = sourceStart, targetIndex = targetStart;
sourceIndex < sourceStop && sourceIndex < this.getLength();
sourceIndex++, tagetIndex++)
{
this.setSampleValueAt(targetIndex, source.getSampleValueAt(sourceIndex));
}
}
There seems like one parameter might be missing. Why is there no parameter:
targetStop -- the index you want to stop copying into in the target sound?
2. Below is the description of the clip method and it’s description. If you call the method asking to start the clip at 1000 and end the clip at 22000, what will be the line of code that will be called to make a new target Sound to hold that clip? (i.e. What is the value of lengthInSamples)
public Sound clip(int start, int end)
{
int lengthInSamples;
//code to calculate lengthInSamples
Sound target = new Sound(lengthInSamples);
//rest of method
}
* @param source the souce sound to copy from
* @param sourceStart the starting index to copy from in the source (the copy will include this)
* @param sourceStop the ending index (the copy won’t include this)
* @param targetStart the index to start copying into
public void splice (Sound, source, int souceStart, int sourceStop, int targetStart)
{
//loop copying from source to target
for(int sourceIndex = sourceStart, targetIndex = targetStart;
sourceIndex < sourceStop && sourceIndex < this.getLength();
sourceIndex++, tagetIndex++)
{
this.setSampleValueAt(targetIndex, source.getSampleValueAt(sourceIndex));
}
}
There seems like one parameter might be missing. Why is there no parameter:
targetStop -- the index you want to stop copying into in the target sound?
2. Below is the description of the clip method and it’s description. If you call the method asking to start the clip at 1000 and end the clip at 22000, what will be the line of code that will be called to make a new target Sound to hold that clip? (i.e. What is the value of lengthInSamples)
public Sound clip(int start, int end)
{
int lengthInSamples;
//code to calculate lengthInSamples
Sound target = new Sound(lengthInSamples);
//rest of method
}
Wednesday, February 27th
1. In the code for halveFreq on page 321 (which lowers the pitch of a Sound), the update in the for-loop increases the value of sourceIndex by 0.5. Which of the following best describes the effect of this increase:
2. According to the textbook, what is the algorithm for blending two sounds?
2. According to the textbook, what is the algorithm for blending two sounds?
Friday, March 1st
1. Under what circumstances can you call a constructor taking no arguments,
WITHOUT explicitly writing it in the class?
. On page 352, after the class Student "No argument constructor" (the one with no parameters), is called,
what is stored in the gradeArray field?
WITHOUT explicitly writing it in the class?
. On page 352, after the class Student "No argument constructor" (the one with no parameters), is called,
what is stored in the gradeArray field?