creation: 7/30/99; small fix: 9/25/09; several questions changed: 2/27/2010; transmogrified: 06/09/2015


Fill in the Blanks Chapter 10

Instructions:   This is a fill-in-the-blank exercise. Each question consists of a sentence with one or two words left out. For each question, think of the word or phrase that should fill each blank, then click on the blanks to see if you are correct.


This exercise reviews simple Java input and output. Much of this is detailed and hard to remember, so don't expect to get every question correct.

1.   When a program does INPUT, data flows _________ the program.

2.   The Java package that contains Scanner is: _______________

3.   Data flows into a program from an input __________ of characters and is written to an _______ ________ .

4.   The standard input stream is __________ .

5.   Examine the following program, which reads in a line of text and then writes it to the monitor. Fill in blanks.

import _____ . _____ . ________ ;   
class Echo
{
  public static void main (String[] args) 
  {
    Scanner scan =  new __________ ( System.in );   

    String inData;

    System.out.println("Enter the data:");
    inData = scan.__________ ;

    System.out.println("You entered:" + inData );
  }
}

6.   An __________ is an object that contains information about what went wrong in an operation.

7.   When a program sends an Exception to a higher level of the system, it __________ the Exception.

8.   To input numeric data, first character data is input, then the characters are __________ into a primitive numeric type.

9.   Examine the following program, which reads in a number and writes its square to the monitor. Fill in blanks.

__________ java.util.* ;  
class EchoSquare
{  
  public static void main (String[] args)
  {
    Scanner scan = new Scanner (__________ );  
    int num, square;                      // declaration of two int variables
    System.out.println("Enter an integer:");        
    num    = scan.__________();  
    square = num * num ;                     // compute the square
    System.out.println("The square of " + num + " is " + square );  
  }
}

10.   If the characters "one hundred forty two" were entered as data for the above program, it would throw an __________ .


End of the Exercise. If you want to do it again, click on "Refresh" in your browser window. Click here to go back to the main menu.