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 4.7 Assessment: Construct A Scanner
Subgoals for using objects (creating instances).
Declare variable of appropriate class datatype.
Assign to variable: keyword new, followed by class name, followed by ().
-
Determine whether parameter(s) are appropriate (API)
Number of parameters
Data types of the parameters
Exercises Exercises
1.
Q1: Fill in the blanks for the following code, if the purpose of the code is to create a new Scanner instance called input
.
________ ________ = ________ ________ (________)
A B C D E
Fill in blank A.
Scanner
input
new
System.in
2.
Q2: Fill in the blanks for the following code, if the purpose of the code is to create a new Scanner instance called input
.
________ ________ = ________ ________ (________)
A B C D E
Fill in blank B.
Scanner
input
new
System.in
3.
Q3: Fill in the blanks for the following code, if the purpose of the code is to create a new Scanner instance called input
.
________ ________ = ________ ________ (________)
A B C D E
Fill in blank C.
Scanner
input
new
System.in
4.
Q4: Fill in the blanks for the following code, if the purpose of the code is to create a new Scanner instance called input
.
________ ________ = ________ ________ (________)
A B C D E
Fill in blank D.
Scanner
input
new
System.in
5.
Q5: Fill in the blanks for the following code, if the purpose of the code is to create a new Scanner instance called input
.
________ ________ = ________ ________ (________)
A B C D E
Fill in blank E.
Scanner
input
new
System.in
You have attempted
of
activities on this page.