Skip to main content

Section 4.9 ObjUse-WE4-P1

Subgoals for Calling a Method.

  1. Classify method as static method or instance method
    1. If static, use the class name
    2. If instance, must have or create an instance
  2. Write (instance / class) dot method name and ( )
  3. Determine whether parameter(s) are appropriate
    1. Number of parameters passed must match method declaration
    2. Data types of parameters passed must be compatible with method declaration
  4. Determine what the method will return and where it will be stored
  5. Evaluate right hand side of assignment. Value is dependent on method’s purpose

Subsection 4.9.1

Exercises Exercises

1.
2.
Q12: What data type is returned by calling nextLine for an instance of Scanner? (Reading the code for the previous question may provide a hint for this one!)
3.
Q13: Put these lines of code in the proper order to read in a decimal then an integer, in that order.
You have attempted of activities on this page.