You will be given a sheet of standard methods you can refer to during the exam.
You can see a copy of this sheet
here.
Although you need to understand the concepts related to the DrawingPanel, there will not be
any questions on the exam asking you to write or understand code involving the
DrawingPanel or the Graphics objects.
For Java programming, review your labs, your Projects 1 and 2, and the
activities from the lecture notes. Some of these will likely be
part of the exam.
For general knowledge, review Chapters 1-4, Supplement 3G, your
quizzes, and the lecture notes. Understanding the chapter
summaries and self-check problems is a good way to start reviewing
the book material. Below is a table of particular items to pay
attention to:
Note: All the Self-Check Problems are good to do. The above selects a subset of them as examples of what to study.
The terminology, notation, and keywords below are in addition to the
lists in the Exam 1 Review.
Terminology
Hover mouse for more information
branch
object
class
parameter
control structure
precondition
counter
postcondition
cumulative algorithm
return type
exception
roundoff error
index
test
branch
a group of statements controlled by a test
class
a category or type of object
control structure
code that controls other statements
counter
variable that is incremented each time a test is true
cumulative algorithm
computes an overall value incrementally
exception
a runtime error
index
a location in a sequence (such as a String)
object
an entity that contains data and methods
parameter
a value passed to a method
precondition
must be true before a method starts
postcondition
guaranteed to be true when a method ends
return type
the kind of value a method returns
roundoff error
inexact values in doubles
test
a boolean expression used to control statements
Notation
Hover mouse for more information
==
!=
<
<=
>
>=
&&
||
==
equal to
!=
not equal to
<
less than
<=
less than or equal to
>
greater than
>=
greater than or equal to
&&
logical AND
||
logical OR
Keywords
Hover mouse for more information
else
Character
equals
DrawingPanel
if
Graphics
new
Math
return
Scanner
void
String
else
indicates statements to execute when the test is false
equals
method for testing equality of objects
if
indicates a test and statements to execute when the test is true
new
constructs a new object
return
indicates value to send back to method call
void
indicates that no value is returned
Character
a class with static methods for operating on chars
DrawingPanel
a class for creating a window to draw on
Graphics
a class for drawing on windows
Math
a class with static methods for common math operations
Scanner
a class for reading input
String
a class for manipulating strings
Additional Activities
Exam 2 Activities 1
Write a method that has three integer parameters
and returns the minimum value. Write one version using
Math.min. [See Self-Check Problem 12 in Chapter 3.]
Write another version using a nested if statement.
Exam 2 Activities 2
Write a method that has three integer parameters and returns the
median (middle) value. [See Self-Check Problem 24 in Chapter 4.]
Exam 2 Activities 3
Write a method that has two parameters, a Scanner and
a String, and returns an int. The method should
use the String to prompt the user and use
the Scanner to input the value. That is, we want to
replace this code:
System.out.print("Enter your most favorite integer: ");
int mostFavorite = console.nextInt();
System.out.print("Enter your least favorite integer: ");
int leastFavorite = console.nextInt();
with:
int mostFavorite = getInt(console, "Enter your most favorite integer: ");
int leastFavorite = getInt(console, "Enter your least favorite integer: ");
Write two other methods, one for inputting a double and the
other for inputting a String. Write a Java program for
testing your methods.
Exam 2 Activities 4
Create modified versions of the
countLetters method on pp. 256-257 to
perform the following tasks.
Count the number of lower case letters.
Count the number of digits.
Count the number of digits and letters.
Count the number of blanks.
Write a Java program that inputs lines from the user and prints
the results of these methods for each line.
Exam 2 Activities 5
Write a Java program to input 10 doubles from the user
and print the minimum. Hint: Modify the MaxInput program in
the lecture notes.
Now modify your program so it also prints the maximum and the average.