revised: 7/17/99; 10/04/03

on Object Parameters

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.

1. What is an actual parameter?

A.    The identifier used in a method to stand for the value that is passed into a method by a caller.
B.    The value that is passed into a method by a caller.
C.    A variable used to control a counting loop.
D.    The value that is returned by a method.

2. What type of parameter passing is used by Java?

A.    Call by value.
B.    Call by object.
C.    Call by parameter.
D.    Call waiting.

3. If a method assigns a new value to a primitive parameter, will this have any effect on its caller?

A.    No, because all the method has is a copy of its caller's values.
B.    No, because the method is not allowed to change the value of any parameter.
C.    Yes, the change will affect the matching value in the caller.
D.    Yes, because the method and its caller share the same section of memory.

4. If a method assigns a new object to an object reference parameter, will this have any effect on its caller?

A.    No, because this will not affect any object that the caller can reference.
B.    No, because this is not a legal operation.
C.    Yes, because now the caller can reference the new object.
D.    Yes, because the new object will replace one of the caller's objects.

5. If a method assigns a new value to a member of an object it can access through an object reference parameter, will this have any effect on its caller?

A.    No, because it only has a copy of the object.
B.    No, because it is not allowed to do this.
C.    Yes, this will change part of the object that both it and the caller are referring to.
D.    Yes, the caller will now get a new object.

6. How can a method communicate a primitive value back to the caller?

A.    It can assign the value to one of its parameters.
B.    It can return the value to the caller using a return statement.
C.    A method can never communicate with its caller by any means.
D.    It can call its caller with the correct value.

7. If a method has a reference to an immutable object, such as a String object, can the method make a change to the object?

A.    No, immutable objects can't be changed by anyone after they have been created.
B.    No, only the creator of an immutable object can change it.
C.    Yes, if it has a reference to an immutable object it can change it.
D.    Yes, but it must use the special "+" operator to do so.

8. Can a programmer (you) design a class whose objects are immutable?

A.    No, only a few pre-defined Java classes like String are immutable.
B.    No, all pre-defined classes are immutable, and all programmer defined classes are not.
C.    Yes, by making all instance variables of the class private.
D.    Yes, by making all instance variables and member methods private.

9. How many references can there be to a single object?

A.    Only one.
B.    Two: one in a caller and one in the called method.
C.    Three: the original reference, and one reference each for a formal and an acutal parameter.
D.    There can be any number of references, held in any number of variables and parameters (as long as they are of the correct type.)

10. Examine the following:

String mess = "Hello" ;
mess = mess + " World" ;
What does the second statement do?

A.    It adds the characters World to the String object referenced by mess.
B.    It creates a new String object based on the original object referenced by mess and another String object containing World.
C.    It alters the immutable object referenced by mess.
D.    It is illegal because it attempts to alter an immutable object.

The number you got right:       Percent Correct:       Letter Grade:   

Click here

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.