Quiz 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 just 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 on reload to clear the old answers.)