Skip to main content\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 7.5 WrMethods-WE2-P1
Subsection 7.5.1 Subgoals for Writing Methods
Define method header based on problem
Define return statement at the end
-
Define method body/logic
Determine types of logic (expression, selection, loop, etc)
Define internal variables
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.