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: Into a Method and Back. 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.
Into a Method and Back
This reading explains how a Java program jumps into a method, runs its lines and comes back to `main`.
Where a Program Starts and Where It Goes
A Java program starts in `main`, even when `main` is not at the top of the file, and the Java Language Specification states that the Java Virtual Machine "starts execution by invoking the method main" of a class. A method is a named group of lines inside a class, and its lines run only when another line calls the method by its name. When a line in `main` calls a method, control jumps to the first line inside that method, the method's lines run in order, and then control comes back to `main` at the line right after the call. A `void` method completes its job and brings no value back to `main`. Oracle's Java tutorial states that a method returns to the code that called it when it "completes all the statements in the method."
One Worked Example
The program below has a method named `greet` written above `main`, and its lines are numbered the way the bench's code panel numbers lines, so the blank line 6 counts as a line.
1public class Main { 2 public static void greet() { 3 System.out.println("Predict first."); 4 System.out.println("Then ask."); 5 } 6 7 public static void main(String[] args) { 8 System.out.println("Start"); 9 greet(); 10 System.out.println("End"); 11 } 12}
Start Predict first. Then ask. End
The lines run in the order 8, 9, 3, 4, 10, and the table below gives one row for each step.
Step | Line | What happens 1 | 8 | main starts and prints Start 2 | 9 | greet(); calls greet, so control jumps into greet 3 | 3 | greet prints Predict first. 4 | 4 | greet prints Then ask. 5 | 10 | control is back in main, which prints End
Step 1 is line 8, because the program starts in `main`, and lines 2 to 5 are skipped on the way down, since a method's lines run only when the method is called. Step 2 is line 9, where the call `greet();` sends control to line 3, the first line inside `greet`. Steps 3 and 4 run lines 3 and 4 in order, and each one prints one complete line of output. After line 4, `greet` has no more lines, so control goes back to `main` right after the call on line 9. Step 5 is line 10, which prints End, and then the closing brace of `main` ends the program.
What the Bench Checks
In today's bench, B17 Into a Method and Back, a student clicks the lines in the order they run. The bench catches two common mistakes, and the first is running a method's lines at the spot where the method is written, which starts the order at line 3 instead of line 8. The second is forgetting to come back, which stops the order after line 4 and never reaches line 10. A wrong click shows "Not yet," names the line that does not run at that step, and counts as one misstep. The bench also demonstrates one more idea, which is that a method called twice runs its lines twice.
Sources: Oracle, The Java Language Specification, SE 21, 12.1 and 15.12.4.5 (n.d.); Oracle, Returning a Value from a Method (n.d.); classroom data, B17 Into a Method and Back and Main.java run with Java 21 (2026).
Web Addresses and DNS
This section explains the parts of a web address and how a browser uses one to find the host that holds a site.
Hosts on the Internet
As Monday's lesson explained, a site's files have to be deployed to a host that is on the internet before other people can open the site. 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 the browsers that ask for them. Other machines find a device on the internet by its IP address, and every connected device has one. An IP address in the older form, called IPv4, is four numbers separated by dots, such as 104.21.7.78, and the newer IPv6 form is longer and uses numbers and letters separated by colons.
The Parts of a URL
A URL is the full address of one page or file on the web, and the letters stand for Uniform Resource Locator. A URL has three main parts, and they always appear in the same order. The first part is the scheme, which names the method the browser uses to ask for the page, and most sites use the scheme https. The second part is the domain name, which names the host, and the third part is the path, which tells the host which page or file the browser wants. Figure 1 splits the address of today's bench, shown below, into these three parts.
https://muggsofcompsci.net/cs1/bench/b17
In this URL, the scheme is https, followed by the characters ://, the domain name is muggsofcompsci.net, and the path is /cs1/bench/b17. The path works like the file paths from the Nov 9 lesson, because it names each step of the route with a slash between the steps. MDN, a guide for web builders, explains that a path once named a real file stored on the host, and that today it is often only a name the host uses to choose what to send. For that reason, a path names a page or a file. Every bench in this class shares one domain name, and only the path changes, from /cs1/bench/b17 today to /cs1/bench/b18 tomorrow. A domain name alone is not a full URL, because the name muggsofcompsci.net tells a browser which host to reach but gives no scheme and no path, so it does not point to one page.
Domain Names and DNS
A domain name is a name that stands for a host, so that people can type words where computers use numbers. MDN notes that IP addresses are hard to remember and can change over time. A domain name is not the host itself, because the host is a computer and the domain name is a label that is matched to that computer's IP address.
DNS, the Domain Name System, is the system that finds the IP address for a domain name. Figure 1 shows the steps in order. First, the browser asks DNS for the IP address that matches the domain name in the URL. Next, DNS returns the IP address, and then the browser sends its request to that IP address, with the path inside the request. Finally, the host sends the page back to the browser. A computer also keeps recent answers for a short time, so it does not have to ask DNS again for every page. DNS does not hold a site's pages, because it only answers the question of which address a name belongs to.
DNS replaced an older method of matching names to addresses. RFC 1034, a 1987 document that describes DNS, explains that the names and addresses of hosts were once kept in a single file called HOSTS.TXT, and every host had to copy it. The work of sending out new copies grew quickly as the network grew, so the designers built a distributed database, which is a set of records spread across many servers.
A Real Lookup
The lookup below was made for muggsofcompsci.net on Oct 19, 2026, with a command called Resolve-DnsName on a Windows computer.
Name Type TTL Section IPAddress ---- ---- --- ------- --------- muggsofcompsci.net A 300 Answer 172.67.135.225 muggsofcompsci.net A 300 Answer 104.21.7.78
DNS returned two IPv4 addresses for one domain name, 172.67.135.225 and 104.21.7.78, and a second lookup on the same day also returned two longer IPv6 addresses. Both IPv4 addresses belong to Cloudflare, the company whose servers answer for the class site. A domain name can point to more than one IP address, and the browser needs only one of them to send its request. A lookup on another day may return different addresses, because the addresses behind a name can change.
Summary
A URL is the full address of one page or file, and its three main parts are the scheme, the domain name and the path. A domain name stands for a host, and DNS finds the IP address for that domain name. The browser then sends its request to that IP address, and the path tells the host which page or file to send.
Sources: MDN, What is a URL? (2026); MDN, What is a domain name? (2025); Cloudflare, What is DNS? (n.d.); Cloudflare, What is my IP address? (n.d.); Cloudflare, IP Ranges (n.d.); Cloudflare, What is round-robin DNS? (n.d.); Mockapetris, RFC 1034 (1987); course passage, Files, Folders and File Paths (2026); course passage, Hosts, Deploys and Static Sites (2026); classroom data, DNS lookup and bench address check (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. The class calendar is at https://muggsofcompsci.net/cs1/calendar. Which list names its three main parts, in order?
- https · muggsofcompsci.net/cs1 · /calendar
- https · muggsofcompsci.net · /cs1/calendar
- https://muggsofcompsci.net · /cs1 · /calendar
- muggsofcompsci.net · /cs1/calendar · https
MC 2. A browser asks DNS about muggsofcompsci.net. What comes back to the browser?
- The path of the page the person wants to open
- A list of search results that match the name
- One or more IP addresses that match the name
- The scheme the browser should use, such as https
MC 3. According to the passage, what does a domain name stand for?
- One page of a site, such as today's bench
- The folder on the host where the site's files are kept
- The browser on the computer of the person visiting
- A host, which DNS matches to that host's IP address
MC 4. A class makes a web page about its neighborhood. Why must the page's files be deployed to a host on the internet before other people can open it?
- Other people's browsers can reach the files only on a computer that is connected to the internet and answers their requests.
- A page can be opened only after a search engine has listed its address.
- Deploying turns the page's code into Java so that every browser can read it.
- Deploying checks the page for mistakes, and a browser opens only checked pages.
MC 5. Which line runs first when this program runs?
1public class Main { 2 public static void bell() { 3 System.out.println("Ring"); 4 } 5 6 public static void main(String[] args) { 7 System.out.println("Class starts"); 8 bell(); 9 System.out.println("Class ends"); 10 } 11}
- Line 3, because it is the first println in the file
- Line 2, because bell is the first method in the file
- Line 7, the first line inside main
- Line 8, because main starts by calling bell
MC 6. In the program from MC 5, which line runs right after line 8, the call bell();?
- Line 9, because main's lines always run in order
- Line 3, the first line inside bell
- Line 7, because the call sends control back to the start of main
- Line 2, because the method's first line is its name
MC 7. In the program from MC 5, line 3 is the last line inside bell. Which line runs after line 3?
- Line 8, so that bell is called a second time
- Line 7, the first line of main
- None, because the program stops when bell ends
- Line 9, the line right after the call
MC 8. This program has main written above the method it calls. What does it print, in order?
1public class Main { 2 public static void main(String[] args) { 3 System.out.println("Board"); 4 stop(); 5 System.out.println("Ride on"); 6 } 7 8 public static void stop() { 9 System.out.println("Ding"); 10 System.out.println("Canal Street"); 11 } 12}
- Board, Ride on, Ding, Canal Street
- Board, Ding, Canal Street, Ride on
- Board, Ride on
- Ding, Canal Street, Board, Ride on
MC 9. How many times does this program print Toot?
1public class Main { 2 public static void main(String[] args) { 3 System.out.println("Line up"); 4 horn(); 5 horn(); 6 } 7 8 public static void horn() { 9 System.out.println("Toot"); 10 } 11}
- 1, because horn has only one println
- 2
- 3, once where horn is written and once for each call
- 0, because horn is written below main
MC 10. Which list gives the lines of the program from MC 5 in the order they run?
- 7, 8, 9
- 3, 7, 8, 9
- 7, 8, 3, 9
- 2, 3, 6, 7, 8, 9
CR 1. Number the lines of this program in the order they run, using the line numbers shown. Then write exactly what it prints.
1public class Main { 2 public static void drum() { 3 System.out.println("Boom"); 4 } 5 6 public static void main(String[] args) { 7 drum(); 8 System.out.println("Second line"); 9 drum(); 10 } 11}
Write your answer in your lab notebook, labeled CR 1.
CR 2. In two sentences, explain why the lines of a method do not run at the spot where the method is written in the file.
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. In this program, main calls openGate, and openGate calls ringBell. Give the line numbers in the order they run, and write exactly what the program prints.
1public class Main { 2 public static void openGate() { 3 System.out.println("Gate open"); 4 ringBell(); 5 } 6 7 public static void ringBell() { 8 System.out.println("Bell"); 9 } 10 11 public static void main(String[] args) { 12 System.out.println("Arrive"); 13 openGate(); 14 System.out.println("Inside"); 15 } 16}
Write your answer in your lab notebook, labeled CR 3.
CR 4. Name the three parts of the address https://muggsofcompsci.net/cs1/bench/b18, and say which part changes from bench to bench.
Write your answer in your lab notebook, labeled CR 4.
Into a Method and Back
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.