2 Pages

# ReviewOfConceptsThroughChapter4

Course Number: C 251, Fall 2009

College/University: Drury

Word Count: 456

Rating:

###### Document Preview

Review of Concepts through Chapter 4 Basic Data Concepts What is the difference between a class and an object? What is the type of each of the following? o int score; o Pixel pix; o double extAngle; o double [] classScores; o Pixel [] pixelList; What does the new operator do? o Given the declaration double [] classScore;, create an array that will hold 10 scores. o Write the code to assign 10 random scores to the...

##### Unformatted Document Excerpt
Coursehero >> Missouri >> Drury >> C 251

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

of Review Concepts through Chapter 4 Basic Data Concepts What is the difference between a class and an object? What is the type of each of the following? o int score; o Pixel pix; o double extAngle; o double [] classScores; o Pixel [] pixelList; What does the new operator do? o Given the declaration double [] classScore;, create an array that will hold 10 scores. o Write the code to assign 10 random scores to the array. o Write the code to print the 9th score along with an appropriate message to the screen. A 2 dimensional array is also called a matrix. o What does Pixel [] [] pictData; declare? o What is the type of pictData; o Write the code to create a picData object that has 10 columns and 7 rows? o Draw a picture of your structure? Control Structures basic loops This is called iteration-repeating a task over and over. What does a loop do? o Basic syntax while (test condition) statement; for (type variableName=initial value; relational test; adjustment) statement; o If more than one statement is needed then the body must be enclosed in braces. Write the code to sum the classScore array defined above using a for loop. Write the code to print the classScore array a using for loop. Rewrite both as while loops. Pay attention to the concept of priming the loop. For loops can be rewritten as while loops and vice-a-versa. What is a method? General syntax of a method <public | private> returnType methodName(formal parameter list) { statement 1; statement 2; statement n; } Write a method for the Picture class that clears the green component of each pixel in the picture. Note that there are no parameters required and the method does not return anything, it only modifies the picture. So its return type is void. Call the method clearGreen. Write a method for the Picture class that changes the red amount by a given factor. Call the method changeRed. Note that we s...