CISC 1115
Introduction to Programming Using Java
Exam #2 Topics
The Structure of the Exam
- For all topics, you should be able to trace, analyze, and write Java code.
- Questions will for the most part consist of:
- presenting you with a piece of code and asking you what is output — or what the value of one or more variables
are — once the code is executed
- presenting you with a problem description and asking you to write the corresponding code
- asking you what is wrong with a piece of code and/or asking you to repair it
- presenting you with a piece of code and asking you to trace the value of one or more variables
as the code is executed
- Although you will not be asked for definitions of terms (e.g. literal, method header, loop body), you should know them as
they will be used in the text of the questions.
- A substantial portion of the exam will be taken from the Exercises, Reading, Coding, and Testing Labs of the covered lectures (Lectures 6-14)
- While the book is a good supplement, you are only responsible for topics and material in the lecture notes and
the CodeLab exercises / labs. The labs are a great way for you to prepare yourself for the exam.
The exam is cumulative but concentrates on lectures 6-12 (excluding lecture 8).
Here is a detailed breakdown of the new topics from those lectures
Expressions
- Operators
- Logical
!
, &&
, ||
- Short-circuiting of
&&
and ||
- Increment / Decrement
- (String) Concatenation
+
- Using concatenation to convert other types to string (e.g., for printing)
- precedence of logical operators
Methods
Basic Techniques
- Toggling booleans
- Evenness / Oddness
- Swapping / exchanging
- Shifting / rotating
Loops
while
, for
loops, and do
/while
loops
- priming the pump
File and keyboard I/O
- read in data using header values, trailer values, eof
Random Numbers
- The
Random
class
- creating a
Random
object with and without a seed.
- The
nextInt
and nextInt(int)
methods
Tables and Nested Loops
- Using a nested loop to generate a table's values
Formatted Output
- Using the
printf
method to print a table's value in tabular format
- You only have to know how to specify integer (%d) and floating point (%f) formats with a width (e.g. %3d)
Loop Techniques (Techniques II)
- Totalling, counting, searching, and finding the maximum/minimum of a sequence of values (from an ipout file)
- Using a
break
statement or a boolean flag to exit a loop
Arrays
- Declaring, creating, initializing, accessing, modifying, traversing
- elements, index/subscript
- ArrayOutOfBoundException
- Arrays and
for
lops; the enhanced for loop
Array Operations and Techniques (Techniques III)
- first, last, middle and mirror element
- traversing forward and backward
- traversing with a condition
- printing
- initializing using a file with a header value
- minimum/maximum, sum, average
- searching: find and contains
Numeral Systems
- binary, medical, hexadecimal number systems
- converting between any of the above
- simply binary addition