By the time of Exam 2, you
should be able to address each outcome in the following topics:
- Design and write code that implements an arithmetic formula,
using methods from the Java Math class.
- Explain the order of precedence in which arithmetic
operations (+,/,-,*, %) in an expression are evaluated.
- Use parentheses to affect the order in which arithmetic
expressions are evaluated.
- Use the typecast operation (for example: (int) ) to assign a
floating-point value to an integer variable.
- Explain the consequences of typecasting a floating-point
value to an integer (ie: truncation)
- Explain integer division (e.g. why 1/3 results in 0, or 5/2
results in 2)
- Use the increment (++) and decrement (--) operators.
- Use the Scanner class methods such as nextDouble() and
nextInt() to convert string input to numeric values.
- Use the Double.parseDouble() and Integer.parseInt()
methods to convert Strings to numeric values.
- Explain the boolean datatype and what values a boolean
variable may represent.
- Design and write boolean conditional expressions using the
relational operators (<, <=, >, >=, !=, ==)
- Design and write compound conditional expressions using the
boolean operators (&& and ||)
- Evaluate complex boolean expressions, such as !( ((x>0) &&
(x<2)) || (y<0) )
- Design and write code that uses if,
else-if and else statements to alter a program's
sequence of execution.
- Design and write code that uses the switch statement to alter
program flow.
- Rewrite an if/else-if/else as a switch statement, and
vice versa.
-
Diagram (e.g.,
flowchart style) how a if/else-if/else changes program flow.
- Design and write code that makes use of the
while or
do-while loop construct.
- Use boolean variables and conditional expressions in a
while or do-while loop to repeat prompts for user input until valid
input is entered.
- Design and write code that makes use of the
for-loop construct.
- Rewrite a given while loop as a
for loop, and vice versa.
-
Diagram (e.g.,
flowchart style) how a while loop changes program flow,
introducing a "loop" in the sequence of statements.
-
Use break to
terminate a loop early
-
Use continue
to repeat a loop early
-
Write loops that
repeat certain operations (summing, evaluating, printing) during each
iteration of the loop.
-
Explain the
scope of a variable declared within a loop construct.
-
Explain the scope
of a variable declared within braces.
Using other classes; calling methods
- Design and write code that makes use of the methods of classes from
tha Java API library (or external libraries), such as JOptionPane,
Math and String, based on reading and interpreting available
documentation for such methods.
- Pass values or variables of the appropriate datatype as arguments
to library methods that have parameters.
- Use a variable of the correct datatype to receive the return
value of library methods that return values.
- Explain the concept of the void keyword with respect to a
method whose return type is void.
- Explain the difference between calling a static method of a
class (ie class method) and a non-static (ie instance method) of
a class.
Object-oriented programming
- Explain what an object is and how it relates to a class.
- Explain the difference between an object's attributes (data) and
data (variables) that are local to a method, and explain how to
distinguish between those pieces of data when both have the same name.
- Explain the concept of this.
- Explain the concept of static (ie class) attributes vs.
non-static (ie instance) attributes.
- Explain what is represented by a variable used to refer to an
object (e.g. Account a = new Account() - what does a actually contain?)
- Explain what happens to an object in memory when a variable used to
reference that object is reassigned or set to null.
- Explain the concept of a class constructor.
- Explain the concept of a default constructor and how & when
it is automatically created.
UML and Object-oriented programming
- Read and understand UML class diagrams.
- Write the method signatures for methods specified in a UML class diagram.