Week 1 · Wednesday, Jan 6 · 1.3
Three kinds of errors
A Java program is a class with a main method, and when it goes wrong the error is compile-time (the compiler rejects it), run-time (it stops partway), or logic (it runs but does the wrong thing).
Minutes for each part of a 90-minute class.
Today we will
- The shape of a Java program: a class, a main method inside it, and statements inside main, each ending in a semicolon.
- System.out.println prints its text and then moves to a new line. Statements run top to bottom.
- Compile-time (syntax) error: the compiler finds a broken rule, makes no bytecode, and nothing runs.
- Run-time error: the program compiles and starts, then stops partway with an exception, such as dividing by zero.
- Logic error: the program runs to the end with no message, but does the wrong thing.
- To sort an error, ask two questions: did it compile, and did it run to the end?
Terms
AP topics 1.1 · Learning objectives 1.1.C · Skills 3.A, 3.D, 4.A
Demonstration
Chromebooks open. Follow along on the Follow along jobs in We Do / You Do while Mr. Muggivan works the examples.
We Do / You Do
Follow along, then Part A (with help), Part B (on your own) and stretch. One code for the whole block.
Open We Do / You DoExit Ticket
A few exam-style items to show what you learned today. One code.
Opens only in the last 15 minutes of class on this day.
Missed class? The Do Now and We Do / You Do stay open. Do them any time and submit your codes.