## Java and Math Basics

This includes the primitive types (for the AP exam you just need to know int, double, boolean) and arithmatic expressions. Be sure to cover the remainder operator '%' (also called the modulus operator). Remind students that integer expessions have integer results (throws away any fractional part). Expression with a double in them will give a double result. Also cover Integer.MAX_VALUE and Integer.MIN_VALUE and the fact that they wrap around when you add one or subtract one. Also cover casting to change the type of a value or variable.

Have your students predict what these will do and then try them in DrJava's interaction pane:

1 / 3

1.0 / 3

1 / 3.0

(double) (1 / 3)

((double) 1) / 3

1 % 3

4 % 3

2 % 3

Integer.MAX_VALUE

Integer.MIN_VALUE

Integer.MAX_VALUE + 1

Integer.MIN_VALUE - 1

Review the primitive types on the exam: int, double, and boolean at http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

Review the operator precedence table at http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html

Do the Java Arithmatic Expression Problets at http://www.problets.org/about/topics/home.html

### Link to this Page

- Review for Exam last edited on 25 February 2010 at 7:58 am by user-112136j.dsl.mindspring.com