Skip to main content

Section 7.5 WrMethods-WE2-P1

Subsection 7.5.1 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 7.5.2 Methods-WE2-P1

GIVEN

For questions 23 through 27, fill in the blanks of the following code, which is a public method header that would work for this call:

String fob;
fob = obj.journey(4.1, 6.6, 8);
___A___ ___B___ journey (___C___ one, ___D___ two, ___E___ three)
{
   /* logic */
}

Exercises Exercises

1.

    Q23: Fill in Blank A.

  • public

  • private

  • String

  • void

  • nothing, empty

2.

    Q24: Fill in Blank B.

  • public

  • String

  • double

  • int

  • void

3.

    Q25: Fill in Blank C.

  • public

  • String

  • double

  • int

  • void

4.

    Q26: Fill in Blank D.

  • public

  • String

  • double

  • int

  • void

5.

    Q27: Fill in Blank E.

  • public

  • String

  • double

  • int

  • void

GIVEN

For questions 28 through 32, fill in the blanks of the following code, which is a public method header that would work for this call:

String trouble;
trouble = obj.gasPrice(56, 22, "diesel");
___A___ ___B___ gasPrice (___C___ one, ___D___ two, ___E___ three)
{
   /* logic */
}
6.

    Q28: Fill in Blank A.

  • public

  • private

  • String

  • int

  • double

7.

    Q29: Fill in Blank B.

  • public

  • private

  • String

  • int

  • double

8.

    Q30: Fill in Blank C.

  • String

  • int

  • double

  • void

  • nothing, empty

9.

    Q31: Fill in Blank D.

  • String

  • int

  • double

  • void

  • nothing, empty

10.

    Q32: Fill in Blank E.

  • String

  • int

  • double

  • void

  • nothing, empty

You have attempted of activities on this page.