Skip to main content

Section 4.7 Assessment: Construct A Scanner

Subgoals for using objects (creating instances).

  1. Declare variable of appropriate class datatype.
  2. Assign to variable: keyword new, followed by class name, followed by ().
  3. Determine whether parameter(s) are appropriate (API)
    1. Number of parameters
    2. 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.