Test 1 Review Guide

Test date: Wednesday, February 25, 2015
Test location: normal lecture hall (you MUST go to your assigned section)
Test duration: 50 minutes (for 1110 and 1111)
Test format: writing on paper; bring pen/pencil (and nothing else)
Review session: Tuesday, February 24, 6:00-7:00 PM in Wilson 402 (run by the TAs); Also open breakout sessions in Wilson 306, 7:30-10:30 PM

Review Sheet

General Points:

  • There will be a coding question; problem solving will be involved.
  • You should be able to read code and interpret what it is doing.

Not on the test:

  • The encryption chase itself is not on the test.
  • Parts of Java we explored only through Turtle are not on the test (e.g., writing methods is not on the test)
  • You do not have to know what to import to get access to various classes.
  • JOptionPane is not on the test (you should not use JOptionPane in any of your code on the test)

CS in General:

  • Where do we see computers in the world?
  • What is ambiguity? What has that got to do with CS?
  • Why is it important for people to have a basic understanding of computing?

Parts of a Program: be able to identify, write, and know where to place

  • import statements (assuming we tell you what to import)
  • class declarations
  • the main method header
  • { }, ( ), ;, and .

Primitives and Types:

  • Know what the 8 primitive types are
  • Know in detail the 4 main ones (int, double, char, boolean) since you’ll be coding with them
  • Know how casting works (i.e., how to turn a double into an int)
  • Know the operators, including %, +=, ++, how / differs for ints and doubles, and the various comparison and boolean operators (!, &&, and ||)
  • Know how to declare a variable and change what is inside it
  • Know how to use the Math library methods Math.pow, Math.sqrt
  • Know how to use the Integer library method Integer.parseInt and the Double library method Double.parseDouble

Using objects:

  • Know that all types other than the 8 primitives are objects
  • Know to use .equals() on objects, not ==
  • Know how to make a new object of a given type
  • Know how to invoke a method (i.e., . and ())
  • Know the basic String methods (charAt, length, replace, split)
  • Know the basic Scanner methods (the various next____ and hasNext____)
  • Know the basic Random methods (to use new Random() not new Random(n), and what the n means in nextInt(n))
  • Know how to create a File object and use it to make a Scanner

Decision structures:

  • Know how to write if, if-else, and if-elseif-else statements
  • Know how to interpret code that uses if, if-else, and if-elseif-else statements, including ifs inside of other ifs
  • Know how scope works: a variable declared inside a block vanishes when that block closes
  • Know in general what a switch statement is

Loops:

  • Know how to write while and for loops
  • Know how to read code that uses do-while, while, and for loops
  • Know how to write a loop that repeats something a given number of times and a loop that reads all of the available input from a Scanner

Reading Files:

  • Know how to read a file, line for line, and to split each line so that you can process individual data items
  • Know the difference of how to read a File vs. reading from a URL (with .openStream())

Using arrays:

  • Know that String’s split method returns an array
  • Know how to declare array variables (e.g., String[] name)
  • Know how to access particular elements of an array (e.g., name[3] is the 4th element)

Study Hints

Practice coding on paper

You’ll be writing code on paper. This feels different than writing it in Eclipse. You don’t want to be surprised by how different it feels. Practice writing code by hand.

A few small syntax errors is OK. But if you are really off we will take off points. Try to write correct code

We’ll usually give you the basic wrapper and have you fill in the rest. For example, we might give you this:

import java.util.Scanner;

public class Question2 {
    public static void main(String[] args) {

(we’ll leave space here for you to write)

    }                                       
}

Try re-solving the POTD and Lab problems on paper without looking at your code or textbook.

You can find more sample problems in Programming Challenges in the textbook; try, for example, chapter 3’s problems 8, 12, 15, and 16; and chapter 4’s problems 2, 7, 8, 9, and 16.

Also remember that speed matters. 50 minutes is not a long time.

Practice reading code

We will show you code and ask you what it does. You won’t be able to have Java run it. Practice thinking through code without running it.

Review the Lectures

Not everything in the book is equally important. Review the lecture notes to see what we emphasized. If you are confused by some point, check the audio. You might want to listen to the audio of the other instructor (the one you didn’t hear in class) so that you can get a different perspective on the material.