creation: 7/30/99

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. No grade is calculated for this exercise.


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 IO package that we will be using is called

3.   java.io does input from an input of characters and does output to an of characters.

4.   An object is created by a Java program using the operator.

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)
{ BufferedReader stdin =
new ( new InputStreamReader( System.in ) );
String inData; System.out.println("Enter the data:");
inData = stdin.
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.io.* ;
class EchoSquare {
public static void main (String[] args)
{ BufferedReader stdin =
new BufferedReader( new ( System.in ) );
String inData; int num, square; // declaration of two int variables System.out.println("Enter an integer:"); inData = stdin.readLine();
num = Integer.( inData );
square = num * num ; // compute the square System.out.println("The square of " + inData + " 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.