Match the following.

 

1.______ An instance of a class. The fields have values and the methods can be called for the object.

 

2.______ Performs action on the object by using the values of the fields.

 

3.______ All field values of an object.

 

4.______ Specifies the type of data value of a field or parameter.

 

5.______ Defines common fields (attributes) and methods (actions) to objects.

 

6.______ Translate Java statements to computer instructions.

 

7.______ Specify values to be used by methods.

 

­­­8.______ Methods pass information back as (?)

 

9.______ Defines method name, number of parameters, name of parameters,   class of parameters, return value class

 

 

  1. Parameters
  2. Compile
  3. Signature
  4. Method
  5. Object
  6. Class
  7. State
  8. Return Values
  9. Data Type

 

 

10. Determine whether the following contain formal parameters or actual parameters.

 

a.) public void studentData(String Name, int idNumber){}                     formal               actual

 

b.) class1.studentName(“Kim”);                                                            formal               actual

 

c.) class1.studentID(“11111”);                                                  formal               actual

 

d.) public void studentID(String ID){}                                       formal               actual

 

 

11. Determine the result class and/or parameter class for each of the following methods.

 

a.) public int numberOfBooks( ){}

                       

result class_______________________ parameter class___________________________

 

b.) public void addBooks(String bookTitle){}

 

result class_______________________ parameter class___________________________

 

c.) public String getStudentName ( ){}

 

result class_______________________ parameter class___________________________

 

12. Think about it:

Do you think that if a method has a specified return type (i.e. not void) that it ever requires parameters?

 

13. What keyword is used to create instances? ________________________________

 

 

class1 {

            //fields

 

            //constructor

 

            //methods

public void studentName(String Name){

                        ****code is here****

}//end method

 

}//end class

 

class1.studentName(“5”);

 

14. What, if anything will occur if a method is used in the above manner?

 

________________________________________________________________________

 

 

15. What does a constructor do?

 

________________________________________________________________________


 

 

Answer Key

 

 

  1. (E) Object
  2. (D) Method
  3. (G) State
  4. (I) Data Type
  5. (F) Class
  6. (B) Compile
  7. (A) Parameters
  8. (H) Return Values
  9. (C) Signature

 

 

10.

            a. Formal

            b. Actual

            c. Actual

            d. Formal

 

11.

            a. Result class: int                      Parameter class: void

            b. Result class: void                  Parameter class: string

            c. Result class: string                 Parameter class: void

 

 

12. Yes. A method may require input (parameters) as well as provide output (return values). For example, a method may require a student ID number in order to return the student’s name.

 

 

13. new(). (For example: String student = new student( ); )

 

 

14. Name will be set to ‘5’. Because the parameter is a string, and the input is in string form (i.e. has quotation marks around it), therefore the parameter will be accepted as it is.

 

 

15. Creates an instance of the class (object) and initialize the fields to a known state