Exam 1 Review Topics

 

Chapter 1

·        Binary numbers

·        Program vs. Algorithm

 

Chapter 2

·        Java primitive types: byte, short, int, long, double, float, char, boolean

·        Java relational operators:  >, <, ==, !=, <=, >=

·        Arithmetic expressions

o       Integer arithmetic

o       Floating point arithmetic

o       Operator precedence

·        Casting

·        Strings

·        Printing using System.out.print()

·        Declaring variables

·        Object variables

 

Chapter 3

·        Classes and objects

o       Creating new objects via the new operator

o       Class methods

§         ClassName.methodName()

§         Examples:

·        Math.sqrt(3.5)

·        Character.getNumericValue(‘a’)

o       Object methods

§         ObjectName.methodName()

§         Examples:

·        Turtle t = …;        
t.setHeading(0.0);
t.turnLeft();

·        String s = "Bob Roberts";
int len = s.length();
System.out.println(s.toUpperCase());

o       Defining methods (we’ve done this in lab a lot!)

·        Classes introduced in chapter 3

o       World

o       Turtle

o       Picture

·        Methods introduced in chapter 3

o       FileChooser.pickAFile()

o       Math.abs(int number)

o       Picture methods

§         show() – an object method that causes a picture to show itself

o       Turtle methods

§         forward(int steps) – an object method that causes a Turtle object to move forward the indicated number of steps

§         moveTo(int x, int y) – move turtle to column x, row y

§         penUp() – lift Turtle’s pen so that it doesn’t draw as it is moved

§         penDown() – set turtle’s pen down so that it will draw

§         turnLeft() – turn turtle left 90o

§         turnRight() – turn turtle right 90o

§         turn(int angle) – turn turtle indicated angle (positive turns clockwise, negative turns counterclockwise)

 

Chapter 4

·        Arrays

·        Looping statements

o       The for-each loop

o       The while loop

o       The for loop

o       Nested loops

·        Additional picture methods

o       getPixels()

o       getPixel

·        Using getPixels() and loops

o       Pixel[] pixels = this.getPixels();
for (Pixel p : pixels)
{
   /* do something with p */
}

o       Pixel[] pixels = this.getPixels();
for (int index = 0; index < pixels.length; index++)
{
   /* do something with pixels[index] */
}

·        Using nested for loops and getPixel(x, y)

o       Pixel p;
int columns = this.getWidth();
int rows = this.getHeight();

for (int row = 0; row < rows; row++)
{
   for (int col = 0; col < columns; col++)
   {
      p = this.getPixel(row, col);
      /* do something with p */
   }
}

·        Color objects   

o       Color color = new Color(200, 100, 200);

·        Pixel methods

o       int getRed(),   setRed(int value)

o       int getGreen(),   setGreen(int value)

o       int getBlue(),   setBlue(int value)

o       Color getColor(),  setColor(Color color)

o       int getX(),  int getY()

 

 

Study tips: 

·        Read the chapters 1 – 4

·        Try the problems at the end of each chapter

·        Review the problems from lab