Exam 1 study guide

Labs:

1 and 2

Terms:

overload vs override a method

throws vs throw

polymorphism – given a set of examples, determine which variables can hold polymorphic references.  Write your own example to review.

 

Exceptions:

How does control flow through a try-catch-finally block

Review the lab drivers to be familiar with where and how they used exceptions

Given a code snippet that uses exceptions and says what would print, be able to fill in missing pieces to ensure the code prints what is specified.

What are checked exceptions and how do they differ from other (non-checked) exceptions?

 

Write short code snippets to recover from common exceptions:

NullPointerException

ArrayIndexOutOfBoundsException

IllegalArgumentException

 

File IO:

Classes used to read and write each type of data: text, binary

Classes used to do sequential access vs random access

BufferedReader.mark(), BufferedReader.reset() for doing read-ahead operations.

Given a class read and write methods for writing text files, be able to write a driver to use that class to produce a file with given characteristics.

RandomAccessFile class:

Given a file with a particular record format (same size and format of records throughout), be able to seek to the beginning of some record.

For example: if records are all 40 bytes long, and you want to position the file pointer to the beginning of the last record, you would:

RandomAccessFile raf = new RandomAccessFile(<filename>);

raf.seek(raf.length()-40);