Skip to main content

Section 8.6 Write-Methods-WE2-P2

Subgoals for Writing Methods.

  1. Define method header based on problem
  2. Define return statement at the end
  3. Define method body/logic
    1. Determine types of logic (expression, selection, loop, etc.)
    2. Define internal variables
    3. Write statements

Subsection 8.6.1

GIVEN
For questions 33 through 37, fill in the blanks of the following code, which is a private method header that would work for this call:
robertsDay(5, 7, 22);
___A___ ___B___ robertsDay (___C___ one, ___D___ two, ___E___ three)
{
   /* logic */
}

Exercises Exercises

1.
    Q33: Fill in Blank A.
  • public
  • private
  • String
  • void
  • nothing, empty
2.
    Q34: Fill in Blank B.
  • public
  • String
  • double
  • int
  • void
3.
    Q35: Fill in Blank C.
  • public
  • String
  • double
  • int
  • void
4.
    Q36: Fill in Blank D.
  • public
  • String
  • double
  • int
  • void
5.
    Q37: Fill in Blank E.
  • public
  • String
  • double
  • int
  • void
GIVEN
For questions 38 through 40, fill in the blanks of the following code, which is a private method header that would work for this call:
double twelve;
int eleven;
eleven = getLength(twelve);
___A___ ___B___ getLength (___C___ one) { /* logic */ }
6.
    Q38: Fill in Blank A.
  • public
  • private
  • String
  • int
  • double
7.
    Q39: Fill in Blank B.
  • public
  • private
  • String
  • int
  • double
8.
    Q40: Fill in Blank C.
  • String
  • int
  • double
  • void
  • nothing, empty
GIVEN
For questions 41 through 45, fill in the blanks of the following code, which is a public method header that would work for this call: obj.fixThings("no", true, "yes");
___A___ ___B___ fixThings (___C___ one, ___D___ two, ___E___ three)
{
   /* logic */
}
9.
    Q41: Fill in Blank A.
  • public
  • private
  • String
  • void
  • nothing, empty
10.
    Q42: Fill in Blank B.
  • public
  • String
  • double
  • boolean
  • void
11.
    Q43: Fill in Blank C.
  • public
  • String
  • double
  • boolean
  • void
12.
    Q44: Fill in Blank D.
  • public
  • String
  • double
  • boolean
  • void
13.
    Q45: Fill in Blank E.
  • public
  • String
  • double
  • boolean
  • void
You have attempted of activities on this page.