Challenges
Remember the rules for this are
- Try to use only the information given up to this point in this book.
 - Try not to give up until you've given it a solid attempt
 
Challenge 1
What will this program output when run? Write down your guess and then try running it.
void main() {
    String mascot = "The Noid";
    IO.println(mascot);
    mascot = "Pizza the Hut";
    IO.println(mascot);
    mascot = "Little Caesar";
    IO.println(mascot);
}
Challenge 2
Why won't this code run? Make it run by only changing one line.
void main() {
    String fruit;
    fruit = "apple";
    IO.println(fruit);
    final String vegetable = "carrot";
    IO.println(fruit);
    IO.println(vegetable);
    fruit = "orange";
    vegetable = "celery";
    IO.println(fruit);
    IO.println(vegetable);
}
Challenge 3
What is the output of this code?
void main() {
    String a = "A";
    String b = "B";
    b = a;
    a = b;
    b = a;
    a = b;
    IO.println(a);
    IO.println(b);
}
Challenge 4
Only adding lines in the middle and without writing "A" or "B" again,
make it so that the output of the program is
B
A
void main() {
    String a = "A";
    String b = "B";
    // Don't touch above this
    // You can add code here
    // Don't touch below this
    IO.println(a);
    IO.println(b);
}
To be clear: you are not allowed to write b = "A"; or a = "B"; 
Hint 1:
You can always make new variables.
Hint 2:
What you need to do is make a "temporary variable" to hold one of the values before you swap them.
Solution
String temp = a; a = b; b = temp;
Challenge 5
Some of the variables in this program are named "wrong."1 Fix them.
void main() {
    String apple = "red";
    String clown_car = "polka dot";
    String SeriousCar = "black";
    String FASTRunner = "bolt";
    String slowRunner = "tortoise";
}
1
                    By currently prevalent social conventions. None are actually "wrong" from the perspective of Java.