Introduction to Programming (Java)
Variables, operators, conditions, loops, methods, arrays and first classes.
Textbook: Paul Deitel, Harvey Deitel, Java: How to Program, 9th Edition, 2011, Pearson, ISBN-10: 0132575663, Edition: 10th
- Week 1Introduction
- How a Java program is compiled and runFrom source code to bytecode, from the JVM to the screen: the javac/java chain, the anatomy of a first program and the three kinds of errors. On the midterm it shows up as fill-in-the-blank and short output questions.
- Week 2Introduction to Java Applications /Elementary Programming
- Variables, primitive types and printfDeclaring variables, the eight primitive types, char arithmetic, casting and formatted output with printf. This is where you learn the difference between 7 and 7.0 in output questions.
- Input with Scanner, String basics, ++ and +=Reading numbers and text from the keyboard, String methods (length, charAt, substring, indexOf, equals) and the increment/compound assignment operators. The first lines of writing questions and the sneakiest part of tracing are here.
- Operators: /, % and precedenceInteger division, the remainder operator and Java's order of operations. Half of the “What is printed?” questions come from here.
- Week 3Control Statements: Part 1
- Decision structures: if/else, logical operators, switchif, else if chains, nested if, short-circuiting with &&, || and !, switch and fall-through. On the midterm it comes both as output tracing and as writing getSeason-style methods.
- Week 4Control Statements: Part 2
- Loops: while, for, do-while, break/continue, nested loopsThe three loop types, counting iterations, break and continue, extracting digits and star patterns. The topic worth the most points on the midterm: finding output with a trace table and writing methods with loops.
- Week 5Methods
- Methods: parameters, return, scope, overloading, Math and RandomMethod header, parameter and argument, return and void, pass-by-value, scope, method overloading, the Math class and random number ranges. The foundation of the 'write a method' questions on the midterm.
- Week 6Arrays
- Arrays: declaring, traversing, passing to methodsCreating one-dimensional arrays, default values, length, index errors, enhanced for, sum/max/average and an array going to a method as a reference. The cornerstone of every exam after the midterm.
- Week 7Arrays II
- Array algorithms and ArrayListLinear search, counting, reversing in place, the difference between a real copy and an alias, shifting and checking whether sorted; then ArrayList, the list whose size can change, and its methods. On the exam it comes both as tracing and as writing short methods.
- Week 8Review + Midterm
- Midterm review: weeks 1-7A one-table summary of all the midterm topics from the compile chain to ArrayList, the traps that cost the most points, exam tactics and mixed exam-style questions.
- Week 9Multidimensional Arrays
- Two-dimensional arrays (2D arrays)Tables made of rows and columns: creating them, m.length versus m[r].length, traversing with nested loops, row/column sums, the diagonal, transpose and ragged arrays. On the final it comes as tracing and method writing.
- Week 10Introduction to Classes and Objects
- Classes and objects: fields, methods, get/setA class is a template, an object is an instance made from that template. Creating objects with new, instance variables, the dot operator, private fields and get/set methods, reference variables and null. The biggest topic of the final starts here.
- Week 11Classes and Objects II
- Constructors, UML class diagrams, arrays of objectsConstructors that prepare the object the moment it is born, the default constructor rule, constructor overloading, reading and drawing a UML class diagram, keeping objects in an array and in an ArrayList. The skeleton of the final writing questions.
- Week 12Classes and Objects: A Deeper Look
- this, static members, final constants and toStringthis when a parameter shadows a field, this(...) chaining constructors, static fields shared by all objects, final values that do not change and toString for printing an object readably. The favorite of 'what is printed' questions on the final exam.
- Week 13Classes and Objects: A Deeper Look II
- Composition, enum and passing references to methodsAn object of another class as a field of a class (has-a), enum for fixed sets of values, and the consequences of object references going to a method as a copy: a method can change the object but cannot turn the caller's variable into another object.
- Week 14Case Study
- Case study: a step-by-step gradebook (GradeBook)We combine all the pieces of the semester in one program: the Student class (array field, average, letter grade), the GradeBook class (ArrayList, top student, passing count, search), a printf report and a star histogram. A rehearsal for the final writing questions.