Quiz 7
Version 1

 

 

Quiz for CS 5
Week 7

1. In the method header

public static void myMethod(long i) 
what is the purpose the word void? What about long?

2. Describe the difference between the "formal parameters" and the "actual parameters" of a method.

3. In a method whose header is

public static boolean even(double spam, char beans) 
what are the formal parameters?

4. Can you use a return statement within a method that does not return a value? If so, for what purpose?

5. In any programming language, a program can be divided into sub-programs. What are three common names for the notion of sub-program?

6. What is the formula for calculating "p choose q"?

7. Suppose that the method scramble is defined as :

     public static int scramble(int egg) {
        egg = (egg*35)%4;
        return egg;
     }
Now suppose that we execute the lines:
     int yolk = 5;
     liquid=scramble(yolk);
What are the final values of the variables liquid and yolk?

8. What is wrong with the method header: public static int foo(int a, b, c)?

9. Do the notes for this week explain the meaning of the keywords public and and static used in all our method declarations?

10. In some programming languages, the definition of a method foo must be placed before the definitions of any methods that call foo. Is this true in Java?

Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Sun, Oct 4, 1998 at 12:22:28 PM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_07/quiz.html