CS I · Mon Nov 16 · 16.1 · 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. No Bench Basics today — this is a short or catch-up day.
  4. The exit ticket. It opens 12 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.

A Second Look at Values

This reading works through one Java program that uses three skills from last week's benches: tracing a reassignment, Java math with `int` values, and joining Strings.

One Program, Row by Row

1public class Main {
2    public static void main(String[] args) {
3        int chairs = 23;
4        int rows = chairs / 4;
5        int extra = chairs % 4;
6        chairs = chairs + 1;
7        System.out.println(rows + " rows, " + extra + " extra");
8        System.out.println("Chairs: " + chairs);
9        System.out.println("Total " + 2 + 3);
10        System.out.println(2 + 3 + " total");
11    }
12}
5 rows, 3 extra
Chairs: 24
Total 23
5 total

The trace table below has a Line column, one column for each box, and an Output column. Its line numbers match the numbered program, so line 3 is the first line inside `main`, and an empty cell means that the box does not exist yet.

Line | chairs | rows | extra | Output
3    | 23     |      |       |
4    | 23     | 5    |       |
5    | 23     | 5    | 3     |
6    | 24     | 5    | 3     |
7    | 24     | 5    | 3     | 5 rows, 3 extra
8    | 24     | 5    | 3     | Chairs: 24
9    | 24     | 5    | 3     | Total 23
10   | 24     | 5    | 3     | 5 total

Line 3 stores 23 in `chairs`. Line 4 divides 23 by 4 with two `int` values, so `rows` stores 5, the whole-number part, and the rest is dropped. Line 5 uses the remainder operator, written as a percent sign, so `extra` stores 3, the amount left over after five groups of 4. Line 6 works out `chairs + 1` and stores 24 in `chairs`, which replaces 23, so the old value is gone. Line 7 joins `rows`, the text `" rows, "`, `extra` and the text `" extra"` into one String, so it prints 5 rows, 3 extra. Line 8 prints Chairs: 24, because `chairs` now holds 24. Lines 9 and 10 print Total 23 and 5 total, and the next section explains why those two lines are different.

Why Lines 9 and 10 Are Different

Java works through a row of `+` signs from left to right. On line 9, `"Total " + 2` comes first, and because one side is a String, the 2 is joined on to make `"Total 2"`. Then `+ 3` joins a 3 onto that String, so the line prints Total 23 and not Total 5. On line 10, `2 + 3` comes first, and both sides are numbers, so Java adds them to get 5. Then `+ " total"` joins the text, so the line prints 5 total. The numbers are the same on both lines, and only their order is different.

Today has no new bench, so this reading is optional make-up. Tuesday's bench starts calling methods, and all three of these skills show up inside them.

Sources: Oracle, The Java Language Specification, SE 21, 15.17 and 15.18 (n.d.); course JDK, Main.java (2026).

Hosts, Deploys and Static Sites

This section explains where a website's files are kept, how they get there, and what the computer that keeps them does all day.

What a Host Does

A website is made of files, such as HTML pages, style files, pictures and JavaScript files. A computer that other people's browsers can reach has to store those files. A host is a server that is always on and connected to the internet, and it stores a site's files and sends them to any browser that asks for them. Mozilla's guide for web developers describes this kind of server as a computer that stores a website's files and connects to the internet. The same guide notes that, apart from downtime and system trouble, a dedicated web server stays connected to the internet all the time. For example, when a student opens Bench Basics at 9 in the morning and again at 9 at night, the browser asks the host for the same files both times, and the host sends them.

A computer that is switched off cannot be a host, and neither can a computer that cannot be reached from the internet, because no browser could get the files from it. A repository is also different from a host. As the Nov 11 lesson explained, a repository keeps a project's files together with their full history. Keeping files is a different job from serving them, and a repository does not send its files to browsers as a website. Mozilla's guide calls rented file space on a hosting company's server web hosting.

How a Deploy Works

To deploy a project means to copy its current files to the host. A deploy does not empty the repository. After a deploy, the files are in two places: the repository, which keeps the files and their history, and the host, which serves them. A site can be reached from anywhere only once a deploy has copied its files to a host that is on the internet.

The class site shows how this works, because its files are kept in a repository whose history begins with a commit on April 21, 2026, and the commit deployed on Oct 19 was number 941 in that history. When a change is ready, a person makes a commit and sends it to the repository's copy on GitHub, and that starts a deploy. The deploy builds the site and copies it to its host. The class site's host is Cloudflare, and the site's address is muggsofcompsci.net. On Oct 19, one real deploy of the class site took 2 minutes and 16 seconds from start to finish, so the change reached the host in about 2 minutes.

A commit that has not been deployed is in the history, but it is not on the live site. Until the next deploy, the host keeps sending browsers the older files. For this reason, a fix that is committed but never deployed exists only in the repository.

Static Sites and Code That Runs

A static site is a site whose files are sent to the browser exactly as they are stored. Mozilla's guide calls a server of this kind static because it sends its hosted files to the browser as they are. For example, a one-page site of class rules, made of an HTML file, a CSS file and a picture, is a static site. The host does no work on those files beyond sending them. Figure 1 shows this path from left to right: first a deploy copies the files from the repository to the host, next a browser asks for a file, and then the host sends the file as stored.

The class site is only partly static. Its pictures and style files are stored on Cloudflare as static assets, and Cloudflare's documentation explains that a request for a stored file is answered with that file, without running the site's code. Other addresses on the class site run code each time they are asked. The class endpoint, which Code Coach uses on Thursday, is one of them. Each time a request arrives at the class endpoint, code on the host runs and sends back a new answer instead of a stored file. The class endpoint is therefore not part of a static site, and its work is a separate job from serving files. Figure 1 draws the class endpoint below the host and apart from the row of files for this reason.

Summary

A host is a server that is always on and connected to the internet, and it stores a site's files and sends them to browsers. A deploy copies a project's current files from the repository to the host, so the files end up in both places. A static site's files are sent as stored, while the class endpoint runs code for each request.

Sources: Mozilla, What is a web server? (n.d.); Mozilla, Publishing your website (n.d.); Cloudflare, Static Assets (n.d.); CS I, Repositories, Diffs and Change Logs (2026); class site repository and deploy record (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. The class site has a repository and a host. Which one keeps the site's files together with their history?

  • The host, because it stores every version of the site that was ever deployed
  • The repository
  • The browser, because it keeps a copy after the first visit
  • Both of them keep the full history in the same way

MC 2. Which part sends the class site's files to a browser that asks for them?

  • The repository, because it holds every commit
  • The internet, which makes the site fresh each time
  • The host, a server that is always on and connected to the internet
  • The class endpoint, which runs code for every file

MC 3. What does a deploy copy, and where do the copies go?

  • The history of commits, from the host back to the repository
  • The project's current files, from the repository to the host
  • The project's files, out of the repository, leaving it empty
  • One picture at a time, from the browser to the host

MC 4. A bus schedule site is made of one HTML file, one CSS file and a picture of the route map. The host sends each file exactly as it is stored. Is it a static site?

  • Yes, because its files are sent to the browser as they are stored.
  • No, because a site with a picture has to run code to show it.
  • No, because a static site cannot have a CSS file.
  • Yes, because its route map changes each time a browser asks.

MC 5. What does this code print?

1System.out.println(31 / 6);
  • 5.16
  • 5
  • 1
  • 6

MC 6. What does this code print?

1int left = 40 % 6;
2System.out.println(left);
  • 6
  • 6.67
  • 4
  • 0

MC 7. What value is stored in seats after these three lines run?

1int seats = 12;
2seats = seats + 6;
3seats = seats - 4;
  • 12
  • 18
  • 14
  • 8

MC 8. What does this code print?

1System.out.println("A" + 1 + 2);
2System.out.println(1 + 2 + "A");
  • A3, then 3A
  • A12, then 3A
  • A12, then 12A
  • A3, then 12A

MC 9. A student traced this code and wrote four rows. Which row is wrong?

1int a = 9;
2int b = a / 2;
3a = a % 2;
4b = b + a;
  • Line 1: a is 9
  • Line 2: a is 9, b is 4
  • Line 3: a is 1, b is 4
  • Line 4: a is 1, b is 4

MC 10. What does this code print?

1System.out.print("Rows: ");
2System.out.println(17 / 3 + 1);
  • Rows: 6 on one line
  • Rows: on one line, then 6 on the next line
  • Rows: 6.67 on one line
  • Rows: 171 on one line

CR 1. Trace the snippet below in a table with a Line column, one column for each box and an Output column. Fill one row for each of the five lines, then give what the snippet prints.

1int cups = 38;
2int boxes = cups / 6;
3int loose = cups % 6;
4cups = boxes + loose;
5System.out.println(cups);

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

CR 2. In two sentences, explain why a commit that was never deployed does not change the live site.

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

Figure 1. A deploy copies the files from the repository to a host that is always on and on the internet, the host sends each stored file to a browser that asks for it, and the class endpoint below the host runs code for each request.
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. Give what this snippet prints, and name the line where the value in minutes is replaced. Explain how you got the answer.

1int minutes = 135;
2int hours = minutes / 60;
3minutes = minutes % 60;
4String time = hours + " h ";
5time = time + minutes + " min";
6System.out.println(time);

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

CR 4. Give one reason the class endpoint is a separate job from serving the class site's files.

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

Bench Basics

No bench today

There is no bench on this day. Finish your classwork and move to the exit ticket.

No bench today — the bench pop-up is off for this day.

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.