creation: 8/13/99; revised 01/15/06

Fill in the Blanks

Instructions:   This is an ungraded fill-in-the-blank exercise. Each question consists of a sentence with one or two words left out. A button represents the missing word(s). For each question, think of the word or phrase that should fill each blank, then click on the buttons to see if you are correct.

1.   A program that normally gets its input from the keyboard can get its input from a file using .

2.   The input file must contain only bytes that represent characters and control characters. This type of file is called a .

3.   Fill in the blanks so that AddUp will read from a file called input.dat.

C:\MyDir> java AddUp        

4.   When using the nextInt() method of Scanner, may input integers have a leading +?

5.   When using the nextDouble() method of Scanner, may input numbers have a leading +?

6.   Fill in the blanks so that Process will read input.dat and send its results to output.txt:

C:\MyDir> java Process      

7.   If you use redirection to send output to a file will an existing file of the same name be overwritten?

8.   If you wish to append output to a file, what characters should you use to redirect output to it?

9.   Complete the following program so that it reads in some characters, converts them to an integer, then writes the square of the integer to output.

import java.util.Scanner;
class Square
  public static void main ( String[] args ) 

    int value;
    Scanner scan = new Scanner( );

    System.out.print("Enter a number: ");
    value  =  ;

    System.out.println( "Square is: " +  );

10.   The previous program can be used just as it is for input from a file. However it would be nice to remove the prompt, which is useless for file input. A good way to do this is to: This is a good idea because:

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.