✕ Close

Week 14 · 14.2 · Wed, Nov 4 · Do Now

Do Now

Work every question in your notebook. Do it on your Chromebook with your ID.

  1. Match the braces

    Which line holds the brace that closes main?

    public class Library
    {
        public static void main(String[] args)
        {
            System.out.println("Find a book");
            System.out.println("Check it out");
            System.out.println("Read");
        }
    }
    1. line 2
    2. line 4
    3. line 8
    4. line 9
  2. Count statements

    How many statements does main hold?

    public class Trip {
        public static void main(String[] args) {
            System.out.println("Pack"); System.out.println("Load the car");
            System.out.println("Drive"); System.out.println("Stop for gas");
            System.out.println("Arrive");
        }
    }
    1. 3
    2. 4
    3. 5
    4. 7
  3. Error analysis

    A student says this program prints Five more minutes first. The right answer is Alarm. What mistake did the student make?

    public class Morning
    {
        static void snooze()
        {
            System.out.println("Five more minutes");
        }
    
        public static void main(String[] args)
        {
            System.out.println("Alarm");
            System.out.println("Get up");
        }
    }
    1. The student started at the top of the file instead of at main.
    2. The student matched the braces on lines 4 and 6 wrong.
    3. The student forgot that each statement ends with a semicolon.
    4. The student read main's statements from bottom to top.
  4. Statement

    Which of these is one complete Java statement?

    1. System.out.println("Stop");
    2. System.out.println("Stop")
    3. public class Stop
    4. }
  5. Output

    Write exactly what this program prints, one line for each line of output.

    public class Game
    {
        static void overtime()
        {
            System.out.println("Overtime");
        }
    
        public static void main(String[] args)
        {
            System.out.println("Kickoff");
            System.out.println("Halftime"); System.out.println("Final whistle");
        }
    }
  6. Turn and Talk, Part 1: What went wrong?

    Turn and Talk · Part 1 · talk with your partner first.

    • “I think the mistake is in line ___ because ___.”
    • “I agree / disagree, because ___.”

    A student wrote down this program's output. Talk with your partner: what went wrong?

    public class Morning
    {
        public static void main(String[] args)
        {
            System.out.println("Wake up");
            System.out.println("Eat");
            System.out.println("Go");
        }
    }
    The student's output
    LineShown
    1Go
    2Eat
    3Wake up
    1. The student read the lines bottom to top
    2. The student skipped a line
    3. The student printed the quotation marks
    4. Nothing: the output is right
  7. Turn and Talk, Part 2: Is it right now?

    Turn and Talk · Part 2 · talk with your partner first.

    • “I think it is right now, because ___.”
    • “I think it is still wrong at line ___, because ___.”

    The student tried again. Is it right now?

    public class Morning
    {
        public static void main(String[] args)
        {
            System.out.println("Wake up");
            System.out.println("Eat");
            System.out.println("Go");
        }
    }
    The student's new output
    LineShown
    1Wake up
    2Eat
    3Go
    1. Right: Wake up, Eat, Go, top to bottom
    2. Still wrong: main runs last
    3. Still wrong: it prints all three words on one line
    4. Still wrong: line 7 runs first