CS I · Fri Nov 20 · 16.5 · We Do

Before the bell

You are responsible for all of this before the end of class.

  1. The discussion form in the I Do deck. All three sections. If you are here, this should be done.
  2. Your classwork. This form on the right. Section 1 before the exit ticket pops up; Section 2 past the floor.
  3. Today's Bench Basics activity: Methods Together. It opens later in class and lives on slide 4 of this deck.
  4. The exit ticket. It opens 15 minutes before the bell and lives on the last slide of this deck.
Classwork

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

Methods So Far, and How to Check the Coach

This reading traces one program that uses all three of this week's method skills, and then it gives the routine for checking Code Coach. The deck numbers the lines, so line 11 is `int h = half(7);`.

1public class Main {
2    public static int half(int n) {
3        return n / 2;
4    }
5
6    public static void report(int value) {
7        System.out.println("Half is " + value);
8    }
9
10    public static void main(String[] args) {
11        int h = half(7);
12        report(h);
13        System.out.println(half(10) + 1);
14    }
15}
Half is 3
6

Reading the Signatures

A method's first line, which Bench Basics calls its signature, names its return type, its name and its parameters. Line 2 says that `half` returns an `int` and has one parameter, `n`, which is also an `int`. Line 6 says that `report` returns nothing, because its return type is `void`, and its parameter is `value`. A parameter is a variable in the method's first line, and an argument is the value a call sends in, so in `half(7)` the argument is 7. In `report(h)` on line 12, the argument is the value stored in `h`, and that value lands in the parameter `value`. Because `report` is `void`, its call on line 12 stands alone as a statement, and nothing is stored.

Tracing the Calls

The program starts in `main`, and its first statement is on line 11. The trace table below has one row for each line that runs, and a dash means that the variable is not in use on that line.

Line   n    h    value   Output       What happens
11     -    -    -                    main calls half(7)
3      7    -    -                    half returns 7 / 2, which is 3
11     -    3    -                    the 3 lands in h
12     -    3    -                    main calls report(h)
7      -    -    3       Half is 3    report prints, then ends
13     -    3    -                    main calls half(10)
3      10   -    -                    half returns 5
13     -    3    -       6            5 + 1 is printed

On line 11, `half(7)` returns 3, not 3.5, because dividing two `int` values keeps only the whole part, which is the same trap as Code Coach's second test input. The returned 3 takes the place of the call, and `=` stores it in `h`. On line 12, control goes into `report`, line 7 prints, and then control comes back to line 13, the line after the call. On line 13, the call `half(10)` returns 5, and the program prints 5 + 1, which is 6.

Checking Code Coach in Four Steps

The same program can check Code Coach. First, the student writes a prediction of the output. Second, the student asks Code Coach about a line or the whole code. Third, the student runs the real Java and writes down exactly what it prints. Fourth, the student compares the explanation and the prediction with the real output and decides who was right. The prediction comes first so that the student has an answer of their own before any explanation is read. Running the real Java caught Code Coach's real mistake in October, when it called `int x = 7 / 0;` not Java, because the real compiler accepted the code and the program stopped with an error. Bench B25 uses the same four steps in December.

Sources: Oracle, Defining Methods (n.d.); Oracle, Returning a Value from a Method (n.d.); Oracle, Passing Information to a Method or a Constructor (n.d.); Oracle, The Java Language Specification, Java SE 21 (2023); Code Coach README (2026).

Checking Code Coach Against Real Java

This section checks Code Coach's explanations against the output of real Java and shows why a wrong explanation can sound as sure as a right one.

How Code Coach Makes an Explanation

When a student presses Ask on a bench, the bench page sends a request to the class endpoint. The class endpoint passes that request to Mistral's server, which runs the model, and the answer comes back the same way. The system prompt, the builder's instructions, goes along with every request. Code Coach's system prompt tells the model to explain the code one line at a time and to say exactly what each line prints or stores.

Code Coach does not look anything up, because no list of saved answers exists for it to search. The model will generate each explanation one token at a time, and a token can be a word, part of a word or a single character. For this reason, the same question asked twice can come back in different words. A wrong explanation also comes out in the same fluent sentences as a right one. For each request below, the model had to generate a new explanation, and none was copied from a list of saved answers.

Three Test Inputs and the Real Output

Code Coach has three test inputs, chosen before any testing. On October 19, 2026, each one was sent to Code Coach twice under version 2 of its system prompt, and each Java input was also run with real Java. Figure 1 shows the results row by row.

The first test input is two lines that print text, and real Java prints Go and then Saints.

1System.out.println("Go");
2System.out.println("Saints");
Go
Saints

Code Coach's first run on these two lines said:

Line 1: This prints the text "Go" to the screen.
Line 2: This prints the text "Saints" to the screen.

Together, these two lines print:
Go
Saints

The explanation matches the real output, and the second test input stores the result of 7 divided by 2 and then prints it.

1int x = 7 / 2;
2System.out.println(x);
3

The real output is 3, because dividing two `int` values keeps only the whole part. Both runs said that `x` stores 3 and that the program prints 3, so the explanation matches. The third test input is a sentence of plain English that asks for help with an essay about the Louisiana Purchase. R4 says that Code Coach should say the input is not Java and ask for a snippet. Code Coach's first run replied:

I can only help with Java code. Please paste a short piece of Java that you'd like explained.

That reply meets R4, and across six runs on the three test inputs, no explanation disagreed with the real output or with a requirement.

The Explanation That Was Wrong

A wrong explanation appeared when the builder tried an extra input that divides by zero.

1public class Main {
2    public static void main(String[] args) {
3        int x = 7 / 0;
4        System.out.println(x);
5    }
6}
Exception in thread "main" java.lang.ArithmeticException: / by zero
	at Main.main(Main.java:3)

This code is Java, and the compiler accepts it, but the program stops on line 3 with an error message, because Java does not allow an `int` to be divided by 0. Code Coach was asked about these two lines in five runs. In four of the five, it said the code was not Java and asked for Java. One of those runs said, in full:

This is not Java. Please paste a short piece of Java.

Two other runs began with the words "This is not valid Java code." The claim that the code is not Java is false, and the real compiler disproves it. A detail that sounds right and is false is a hallucination. The model was predicting tokens in the usual way when this happened, and this time the prediction was wrong. The fifth run did describe the crash, saying that Java "will throw an ArithmeticException" on the dividing line. A wrong answer in a student's own prediction is a person's mistake, while a false claim in Code Coach's explanation is a hallucination.

How to Test an Explanation

To test an explanation, a student predicts first, then runs the real Java and compares the explanation's claim with the real output, line by line. A prediction written first gives the student an answer to compare. On the bench, Ask Code Coach opens only after the student checks an answer on that job. Every answer on the bench also carries the line "a model generated this; check it against the code."

Asking Code Coach "are you sure" does not count as a test, because the second answer is generated the same way as the first. Reading the explanation again is not a test either, because nothing new is compared. Running the snippet and comparing the outputs is a test, because the output comes from Java and not from the model. For the extra input, one run of the real program settles the question: the code is Java, and it stops with an error.

Summary

Code Coach's model generates every explanation one token at a time, so a wrong explanation sounds as sure as a right one. Under version 2, all three test inputs matched real Java, but an extra input that divides by zero drew the false claim that the code is not Java in four of five runs. A test means predicting first, running the real Java and comparing its output with the explanation.

Sources: Code Coach README and captures, mistral-small-2603 (2026); Google, Introduction to Large Language Models (2026); Kalai et al., Why Language Models Hallucinate (2025); Oracle, The Java Language Specification, Java SE 21 (2023); class site source code, coach.tsx and class-endpoint.ts (2026).

Classwork · Section 1 — Reading 2

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

MC 1. How did Code Coach make its explanation of test input 2?

  • It found the explanation in a list of saved answers and sent it back.
  • It ran the Java on Mistral's server and described what was printed.
  • The model generated it one token at a time, new for that request.
  • It looked the line up in Oracle's Java documentation and pasted that explanation.

MC 2. Which explanation does the real output disprove?

  • Test input 2: "So, x stores 3."
  • Test input 1: "This prints the text "Go" to the screen."
  • Test input 3: "I can only help with Java code."
  • The extra input int x = 7 / 0;: "This is not Java."

MC 3. Which of these counts as a test of Code Coach's explanation?

  • Asking Code Coach "are you sure" and reading its second answer
  • Predicting first, running the real Java and comparing the output with the explanation
  • Reading the explanation again slowly to see whether it still makes sense
  • Checking that the explanation is long and uses words like int and println

MC 4. Test input 3 is a request for help with an essay. What does R4 require Code Coach to do?

  • Write a short essay, because the student asked politely
  • Explain the sentence one word at a time, as it does for Java
  • Say that the input is not Java and ask for a Java snippet
  • Show "Paste or pick a line first." and send no request

MC 5. The method bell ends after line 3 prints Ding. Which line runs next?

1public class Main {
2    public static void bell() {
3        System.out.println("Ding");
4    }
5
6    public static void main(String[] args) {
7        System.out.println("Start");
8        bell();
9        System.out.println("End");
10    }
11}
  • Line 7, the first line of main
  • Line 6, the header of main
  • Line 9, the line after the call on line 8
  • No line; the program stops when bell ends

MC 6. Using the method half from Reading 2, what value does half(9) return?

1public static int half(int n) {
2    return n / 2;
3}
  • 4.5
  • 5
  • 9
  • 4

MC 7. addTwo(5) returns 7. Where does the 7 end up?

1public class Main {
2    public static int addTwo(int k) {
3        return k + 2;
4    }
5
6    public static void main(String[] args) {
7        int score = addTwo(5);
8        System.out.println(score);
9    }
10}
  • It takes the place of the call on line 7 and is stored in score.
  • It is printed on line 3, where return is.
  • It is stored in k, the parameter.
  • It is lost when addTwo ends, so score stays empty.

MC 8. In Reading 2, line 6 is public static void report(int value) and line 12 is report(h);. Which is the parameter, and which is the argument?

  • h is the parameter, and value is the argument.
  • value is the parameter, and h is the argument.
  • report is the parameter, and void is the argument.
  • Both value and h are parameters.

MC 9. What is printed?

1public class Main {
2    public static int triple(int t) {
3        return t * 3;
4    }
5
6    public static void show(int s) {
7        System.out.println("Score: " + s);
8    }
9
10    public static void main(String[] args) {
11        show(triple(4));
12        System.out.println(triple(2) - 1);
13    }
14}
  • Score: 12 on the first line, then 5 on the second line
  • Score: 4 on the first line, then 5 on the second line
  • Score: 12 on the first line, then 6 on the second line
  • 12 on the first line, then 5 on the second line

MC 10. A student traced this program. Which row of the trace is wrong?

1public class Main {
2    public static int half(int n) {
3        return n / 2;
4    }
5
6    public static void main(String[] args) {
7        int a = half(11);
8        int b = half(a);
9        System.out.println(a + b);
10    }
11}
  • Line 3, first call: n is 11
  • Line 7: a stores 5
  • Line 8: b stores 2.5
  • Line 9: prints 7

CR 1. Trace this program. (1) Write the lines that run, in order, with what each one stores, returns or prints. (2) Write the exact output.

1public class Main {
2    public static int plusTen(int p) {
3        return p + 10;
4    }
5
6    public static void say(int q) {
7        System.out.println("You have " + q);
8    }
9
10    public static void main(String[] args) {
11        int coins = plusTen(15);
12        say(coins);
13        System.out.println(coins / 2);
14    }
15}

Write your answer in your lab notebook, labeled CR 1.

CR 2. Code Coach gave one explanation that the real output disproves. Quote the false claim, and give the real output that disproves it.

Write your answer in your lab notebook, labeled CR 2.

Figure 1. Code Coach's three test inputs and one extra input, each with a short piece of its saved explanation, the real output from Java, and whether the two match.
Classwork · Section 2 — Past the floor

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

CR 3. (For students who were out Thursday) Name the parts that a Code Coach request passes through, in order, from the bench to the model and back. Then explain what the system prompt does.

Write your answer in your lab notebook, labeled CR 3.

CR 4. Java's remainder operator gives what is left over after dividing two int values. Write a fourth test input for Code Coach, two lines of Java, that would catch a mistake about the remainder operator. Then write its expected output, and say what a wrong explanation might claim.

Write your answer in your lab notebook, labeled CR 4.

Bench Basics

Methods Together

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.

Classwork

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

Exit Ticket

This opens during your class period.