Chapter 5: Booleans and Flow Control

The exercises here are taken from my forthcoming book The Java Developer's Resource.

Quiz

  1. Is a float large enough to count the king's wheat?
  2. Why isn't there a ** or a // operator?
  3. Given that b is a boolean variable, what's the value of (b || !b)?
  4. Here's one that stumped the author until he got some help from comp.lang.java. What's wrong with this program?
public class BytePrint {

  public void main(String[] args) {
    for (byte b = -128; b <= 127; b++) {
      System.out.println(b);
    }

  }

}

Exercises

  1. Write the FahrToCelsius program of the last chapter using a for loop instead of a while loop.
  2. Write the combination lock programs of Chapter 3 using for loops.


[ Exercises | Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]

Copyright 1996 Elliotte Rusty Harold
elharo@sunsite.unc.edu
Last Modified August 20, 1996