Read pages 183-208 in the textbook.
Read the section on writing clear code from the book's website.
Some additional comments:
Packages (lesson 17) are named in lower case, with nested names separated by periods. When a domain name is included, it appears reversed at the beginning of the package name. For example, there might be a package called edu.lclark.spacedisagreement.physics.
When an acronym or initialism appears as a word, it should be capitalized as any other word. For example, a variable holding a list of fugitives should be called fbiMostWanted, not FBIMostWanted.
When reading code, if the author has followed these conventions, you will have an easier time determining what is what. For example, in the expression java.lang.Math.cos(x) we can see that java.lang is a package, Math is a class within that package, cos() is a (static) method in that class, and x is a variable, argument, or instance variable.
These conventions are followed widely, but not universally. In fact, you will find many places in the book and even in older parts of the Java libraries themselves where the conventions are violated. For example, the method println() should really be called printLine().
The following classes are referred to in the quiz.
import static stdlib.StdOut.*; public class Hailstone { public static void main(String[] args) { int n = 34; do { println(n); n = advance(n); } while (n != 1); } public int advance(int n) { if (n % 2 == 0) { return n / 2; } else { return (3 * n) + 1; } } }
import static stdlib.StdOut.*; public class Zorch { public static int tweak(int n) { return n / 3; } public static int twiddle(int n) { return n + 1; } public static int frob(int n) { return n * 2; } public static void main(String[] args) { println(tweak(twiddle(frob(5)))); } }
Quiz.