creation: 08/08/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.


Rule for Matching if and else:   Within each pair of matching braces: start with the first if and work downward. Each else matches the closest previous unmatched if. An if matches only one else and an else matches only one if.

1.   Click on the that matches the IF in capitals (of course, in a real Java program the if has to be lower case.)

  IF ( val == 34 )
       sum = sum + val;
  
      sum = sum - val;
  
  if ( sum < limit )
       flag = true;
  
       flag = false;
  
  IF ( val == 34 )
      if ( sum < limit )
           sum = sum + val;
      
          sum = sum - val;
  
      sum = sum + 1;
  
  if ( val == 34 )
       sum = sum + val;
  
      sum = sum - val;
  
  IF ( sum < limit )
       flag = true;
  
       flag = false;
  
  if ( val == 34 )
      IF ( sum < limit )
           sum = sum + val;
      
          sum = sum - val;
  
      sum = sum + 1;
  

2.   Click on the that matches the IF in capitals.

IF ( val == 34 )
{
     sum = sum + val;
     val = 0;
     next= 5;
}

{
    sum = sum - val;

    if ( sum < limit )
         flag = true;
    
         flag = false;
}
  IF ( val == 34 )
  {
      if ( sum < limit )
           sum = sum + val;
  }
  
  {
      sum = sum - val;
      val = sum + 1;
  }
  
  if ( val == 34 )
  {
       sum = sum + val;
       val = 0;
       next= 5;
  }
  
  {
      sum = sum - val;
  
      IF ( sum < limit )
           flag = true;
      
           flag = false;
  }
  
  IF ( val == 34 )
  {
      if ( sum < limit )
           sum = sum + val;
      if ( val >= limit )
           val = sum - limit;
      
           val = 0;
  }
  
      if ( val = -12 )
          sum = 0;
      
          limit = 88;
  

3.   The idea of a controled loop is that there is a special value that says when the loop is done.


4.   The special sentinel value must not be a value that could ever occur in the .


5.   Complete the following fragment so that if data is "Hello" it writes "World".

if ( data. ( "Hello" ) )
    System.out.println("World");



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.