Before the bell
You are responsible for all of this before the end of class.
- The discussion form in the I Do deck. All three sections. If you are here, this should be done.
- Your classwork. This form on the right. Section 1 before the exit ticket pops up; Section 2 past the floor.
- Today's Bench Basics activity: Start to Stop. It opens later in class and lives on slide 4 of this deck.
- The exit ticket. It opens 15 minutes before the bell and lives on the last slide of this deck.
The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.
Start to Stop: The Order a Program Runs
This reading explains where a Java program starts, the order in which its lines run, and where it stops, using one worked program.
Where a Program Starts
A Java program starts at main, even when main is not at the top of the file, and the Java Language Specification states that the Java Virtual Machine starts every program by running the method named main. Java looks for main by name, so main can sit below comments or below other code inside the class and still be the place where the program begins. The program then runs the statements inside main one at a time, from top to bottom, and it stops after the last statement in main. Comments are notes for people, and they do not run, because a comment that begins with two slashes lasts until the end of its line and Java ignores all of that text.
1public class Main { 2 // This program prints the order of a class day. 3 // These comment lines are at the top, but they do not run. 4 // Java starts at main, which is below them. 5 6 public static void main(String[] args) { 7 System.out.println("Board Question"); 8 System.out.println("I Do"); 9 System.out.println("We Do"); 10 System.out.println("Bench Basics"); 11 System.out.println("Exit ticket"); 12 } 13}
Board Question I Do We Do Bench Basics Exit ticket
Numbering the Order
The table below numbers every line of the program, and its Order column shows which lines run and in what order.
Line What the line holds Order Prints
1 class header, opens { -
2 comment -
3 comment -
4 comment -
5 blank line -
6 header of main, opens { -
7 statement 1 Board Question
8 statement 2 I Do
9 statement 3 We Do
10 statement 4 Bench Basics
11 statement 5 Exit ticket
12 closing brace of main - (the program stops here)
13 closing brace of the class -
Lines 7, 8, 9, 10 and 11 run in that order, so they are numbered 1 to 5. Lines 1 to 6 and lines 12 and 13 hold the shape of the program or are comments and a blank line, so nothing is printed from them. The program stops after line 11, when it reaches the closing brace of main on line 12.
Two Mistakes Bench Basics Catches
On B10, a student clicks the lines in the order they run, and each click on a line that does not run next costs 5 points. A wrong click shows "Not yet" with the step number, and a right click shows "Right" and moves the student to the next step. The first mistake is starting at line 1 because it is at the top of the file. Line 1 only names the class, and nothing runs there, so a student who clicks it as step 1 has confused the top of the file with the start of the program. The second mistake is counting a line that does not run, such as a comment or a closing brace. In the worked program, the first click belongs on line 7, even though six lines sit above it. On the bench, each brace sits on its own line, so the line numbers are different from this reading, but the order follows the same rule.
Sources: Oracle, The Java Language Specification, Java SE 21 Edition, §12.1 and §3.7 (2023); CS I, Bench B10 Start to Stop (2026); CS I, Java runs with the course JDK (2026).
Specifications, Requirements and Tests
This section explains how a builder writes down what a tool must do, and how another person can check that the tool does it.
From a Purpose to a Specification
On Oct 26, the class described every tool by its input, processing and output, which explains how a tool works but not what one particular tool must do. A specification is a written description of what a tool must do, exact enough that someone can build from it and someone else can check the result. A specification usually begins with a purpose sentence, which says what the tool is for. The class's example tool, Code Coach, has this purpose sentence: "Code Coach helps a student understand a short piece of Java while reading it." A purpose sentence alone is not a specification, because it says what the tool is for and not what the tool must do. A builder could read it and still not know what Code Coach should do when someone gives it plain English instead of Java.
Requirements That Can Be Tested
A requirement is one statement of something the tool must do. A requirement can be tested when it names a result that a person can observe. NASA's checklist for writing good requirements asks whether a system can be tested, demonstrated, inspected or analyzed to show that it meets each requirement. The same checklist asks whether there is a way to measure the result. Code Coach has five requirements, shown below. R1 to R4 describe Code Coach's answers, and R5 describes the bench, the page around Code Coach, so R5 is built into the bench's code.
R1. Code Coach explains only the Java the student asked about. R2. Every explanation names what the code prints or stores, if it prints or stores anything. R3. Code Coach does not write new code for the student. R4. When the input is not Java, Code Coach says so and asks for a Java snippet. R5. When no line is picked, the bench shows "Paste or pick a line first." and sends no request.
The sentence "Code Coach should be smart" is a wish. It names no result that anyone can check, because nothing in it can be counted, seen or compared, so no test is possible. NASA's checklist names words such as "flexible," "sufficient" and "adequate" as words to avoid in a requirement for the same reason. A rule about speed becomes testable once it has a number, because the word "fast" alone cannot be checked, but a rule that Code Coach answers within 10 seconds can be timed with a clock.
Writing a Test for Each Requirement
A test is a check with three parts: an input, the output that is expected, and a comparison with what the tool actually does. NASA describes a test as using the finished product to collect data on whether each requirement is met. Reading a requirement a second time is not a test, because a test uses the tool. Figure 1 shows one test for each of Code Coach's requirements. These tests were written for this lesson, so the result column is still empty.
The test for R1 gives Code Coach a three-line snippet and picks line 2 only, so the expected output is an explanation of line 2 and of no other line. The test for R2 uses one of Code Coach's three test inputs, shown below with the output that real Java prints.
1int x = 7 / 2; 2System.out.println(x);
3
Because real Java prints 3, the test expects the explanation to say that x stores 3 and that 3 is printed. The test for R3 asks Code Coach to write a program that prints the student's name, and the expected output contains no new code. The test for R4 uses another test input, a request for help writing an essay about the Louisiana Purchase. That input is plain English, so the expected output says the input is not Java and asks for a Java snippet.
The test for R5 leaves the line choice on "Pick…" and presses Ask. The expected output is the message "Paste or pick a line first." with no request sent. A person can observe the second part, because the button never changes to "Asking…" and no answer appears. Each test writes down its input and expected output before it runs, so another person can run it again later and make the same comparison.
Rewriting a Wish as a Requirement
To rewrite a wish as a requirement, a builder first asks what a person would see if the wish came true, and then writes that result down. For example, "The bench should be clear about mistakes" is a wish. A student using the bench would see the words "Not yet" after a wrong answer, and the correct answer would stay hidden. The requirement could read, "When a check is wrong, the bench shows 'Not yet' and does not show the answer." A test for it enters one wrong answer and checks for both results.
Summary
A specification describes what a tool must do, and a purpose sentence is only where it starts. A requirement can be tested when it names a result a person can observe, and a wish such as "Code Coach should be smart" names none. A test gives an input, the expected output and a comparison with what the tool actually does.
Sources: NASA, Appendix C: How to Write a Good Requirement (n.d.); NASA, 5.3 Product Verification (n.d.); CS I, Code Coach README (2026); CS I, Code Coach panel source (2026); CS I, Build Spec v2.0 (2026); CS I, Input, Processing and Output (2026).
The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.
MC 1. A team is writing requirements for a bus-tracker app. Which statement can be tested?
- The app should be smart about bus times.
- Riders should enjoy opening the app every day.
- When a rider picks a stop, the app shows the time of the next bus at that stop.
- The app should be the best bus app in New Orleans.
MC 2. Which list gives the three parts of a test?
- a requirement, a purpose sentence and a specification
- an input, the expected output and a comparison with what the tool actually does
- an input, the tool's output and the builder's opinion of that output
- a careful second reading of the requirement, a class vote and a grade
MC 3. A tester picks the whole code of a three-line snippet that ends with System.out.println(total); and expects the explanation to say that total stores 12 and that 12 is printed. Which of Code Coach's requirements does this test check?
- R1, because the tester asked about the whole code
- R2, because the explanation has to name what is stored and printed
- R3, because the answer should not contain new code
- R4, because the input has to be Java
MC 4. Code Coach's purpose sentence is "Code Coach helps a student understand a short piece of Java while reading it." Why is this sentence alone not a specification?
- It says what the tool is for, but not what the tool must do.
- It is only one sentence, and a specification has to be long.
- It is written in English, and a specification has to be in Java.
- It was written before Code Coach was built.
MC 5. Which line runs first?
1public class Main { 2 public static void main(String[] args) { 3 System.out.println("Red beans"); 4 System.out.println("Rice"); 5 System.out.println("Cornbread"); 6 } 7}
- public class Main {
- public static void main(String[] args) {
- System.out.println("Red beans");
- System.out.println("Cornbread");
MC 6. Which line runs last?
1public class Main { 2 public static void main(String[] args) { 3 int laps = 3; 4 System.out.println("Warm up"); 5 laps = laps + 1; 6 System.out.println(laps); 7 } 8}
- int laps = 3;
- laps = laps + 1;
- System.out.println(laps);
- the closing brace } on the last line
MC 7. Lines 3, 4 and 5 hold the three statements. In what order do lines 3, 4 and 5 run?
1public class Main { 2 public static void main(String[] args) { 3 System.out.println("Doors open"); 4 System.out.println("Band plays"); 5 System.out.println("Doors close"); 6 } 7}
- 3, then 4, then 5
- 5, then 4, then 3
- 4, then 3, then 5
- all three at the same moment
MC 8. Line 3 of this program is a comment. What does line 3 do when the program runs?
1public class Main { 2 public static void main(String[] args) { 3 // Print the score. 4 System.out.println("Saints 24"); 5 } 6}
- It prints the words Print the score.
- Nothing, because a comment is a note for people and does not run.
- It runs first, because it sits above the println statement.
- It stops the program before line 4 can run.
MC 9. Where does this program stop?
1public class Main { 2 public static void main(String[] args) { 3 System.out.println("Ready"); 4 System.out.println("Go"); 5 } 6}
- It goes back to the first statement and prints Ready again.
- It stops after printing Ready, because that is the first statement.
- It stops after printing Go, when it reaches the closing brace of main.
- It stops only after it reaches the closing brace of the class.
MC 10. Lines 2, 3 and 5 are comments, and main starts on line 4. Which line runs first?
1public class Main { 2 // Prints a short weather report. 3 // Written for Bench Basics practice. 4 public static void main(String[] args) { 5 // The temperature comes first. 6 System.out.println("72 degrees"); 7 System.out.println("Sunny"); 8 } 9}
- line 2, because it is the first line inside the class
- line 4, because it is the header of main
- line 5, because it is the first line inside main
- line 6, because it is the first statement inside main
CR 1. Use the line numbers shown beside the code. Write the line numbers of the six statements in the order they run, numbered 1 to 6. Then write exactly what the program prints.
1public class Main { 2 public static void main(String[] args) { 3 System.out.println("Line up"); 4 // Count the team. 5 int players = 5; 6 System.out.println(players); 7 players = players + 1; 8 System.out.println(players); 9 System.out.println("Play ball"); 10 } 11}
Write your answer in your lab notebook, labeled CR 1.
CR 2. A builder writes, "The page should be nice." Rewrite it as one requirement that a person could test. Then describe its test in one or two sentences: the input, and what a person should see.
Write your answer in your lab notebook, labeled CR 2.
The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.
CR 3. Use the line numbers shown beside the code. List the line numbers that run, in the order they run. Then name the line after which the program stops, and explain in one sentence why lines 2 and 3 are not on your list.
1public class Main { 2 // A program for the end of practice. 3 // It prints three lines and stores one number. 4 5 public static void main(String[] args) { 6 System.out.println("Cool down"); 7 int laps = 2; 8 // One more lap before stretching. 9 laps = laps + 1; 10 System.out.println(laps); 11 System.out.println("Stretch"); 12 } 13}
Write your answer in your lab notebook, labeled CR 3.
CR 4. Pick an app you use. Write one requirement for it that a person could test. Then write a test for it with an input and what a person should see, in two or three sentences.
Write your answer in your lab notebook, labeled CR 4.
Start to Stop
Open the bench, do its six jobs, then paste your credit code into the credit-code form. You can turn in up to three codes per bench; your best score is your grade.
Bench Basics opens during your class period.
The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.
This opens during your class period.