You are responsible for all of the material up through Widgets and Message Dialogs.
Java Basics
Make sure you know how to write a Java program
Make sure you understand the differences between C++ and Java
Know how to use pointers to create linked data structures
Java has no stack-allocated objects, including arrays
To create an array of TreeNodes, you must write
TreeNode forest[] = new TreeNode[10];
for (i = 0; i < forest.length; i++)
forest[i] = new TreeNode();
Java I/O
Scanners
For reading lines
For tokenizing lines (remember to close these scanners)
For file I/O (drop a FileReader object into a BufferReader
object which in turn is dropped into a Scanner
object)
String => Number Conversion using Integer.parseInt and
Double.parseDouble
Garbage Collection
Reference Counting
Tracing Collectors
Mark-sweep
Stop-and-copy
Generational collectors
How to execute a Java program
Use the package prefix
Use the -sourcepath or -sp flag to tell the compiler where to
find packages
Use the -classpath or -cp flag to tell the interpreter where to
find packages
How to create and execute a .jar file
1) Use either the -e flag or a manifest file to declare the entry point
2) Must store packages as directories
3) Use -C flag to "cd" to parent directories of package directories
before including the package directory
Collection classes
Know when it is appropriate to use each type of collection class
Know how to sort using the Collections.sort() and list.sort() commands
Maps are not part of Collections so know how to convert parts of a Map
to a collection
1) entrySet() returns Set<Map.Entry<K,V>> which can be
given as a parameter to an ArrayList/LinkedList to create a list of
entries. Note that you can iterate over a Set as well--you do
not need to create a list for iteration but you might for sorting.
2) keySet() returns Set<K> of keys which can be given as a
parameter to an ArrayList/LinkedList to create a list of keys
3) values() returns a Collection<V> which is iterable.
Every Collection (e.g., LinkedList, ArrayList, Set, etc) has a constructor
that accepts a Collection as an argument and creates the appropriate
object from that Collection. Hence any Map's keys, values, or key/value
pairs can be converted to any Collection object by using one of the
above three commands to get a Collection and then passing the result
to the appropriate constructor.
Inheritance
How to draw an inheritance tree
Interfaces versus classes
interfaces are declarations of types (specify an API)
classes are concrete implementations of types (provide implementation)
Types/Subtypes and Classes/Subclasses: Note the relationship
between types/classes and also that subinterfaces represent
subtypes
i. Abstract type: A set of operations only (Stack)
ii. type: A set of values + a set of operations (Stack of ints)
Virtual methods: Know the difference between virtual, pure virtual,
and non-virtual methods
i. virtual methods provide an implementation that may be
overridden by a subclass
ii. pure virtual methods: provide no implementation and hence
subclasses must provide an implementation
iii. non-virtual method: a method whose implementation must be
accepted by all subclasses (i.e., it cannot be overridden)
Know Java and C++ syntax for inheritance (abstract, extends, implements,
access modifier before each method)
C++ Inheritance Issues
1) Initialization lists for constructors and why they are more
efficient than assignments in constructor bodies
2) Multiple inheritance
a) What it is
b) Shared versus replicated inheritance
3) How to inherit implementation but not interface by subclassing
using the protected keyword
Modules
Packages (Java)
Namespaces/Friends (C++)
void */putting structs in .c rather than .h files to hide
implementation (C)
Disadvantages of Friends
one-way: requires O(n^2) declarations to share implementation
among n classes
not inherited: subclasses must also be declared friends
Java adds package-level access: know the difference between
package-level and protected access
Generics (Templates)
Polymorphism-Parametric versus subtype
parametric (templates): same piece of code operates on different
types
explicit (C++, Java): explicitly provide the type parameters
implicit (scripting and functional languages): the runtime
environment infers the types of the parameters
subtype (inheritance): different piece of code may operate on
different types but the behavior must be the same
Know how to write a template class in Java and C++
Use void * in C to get generic functions/data structures
Template Properties
Java C++ C
Compilable yes no yes
Primitive Types no yes no
Java uses type erasure to compile template code: it replaces each
type parameter with its upper bound
Exceptions
Try/throw/catch in Java/C++
use try/catch rather than exit so that stack frames get popped
and destructors executed in C++. These destructors can
do the appropriate thing with partially completed resources.
setjmp/longjmp in C
variables stored in registers may be lost
volatile variables solve the problem but require a write-through
to memory which can jam the processor pipeline
know how to write Java and C++ code with exceptions
1) try/catch: try executes error-free code and catch executes
error handling code
2) throw: does not have to appear in a try statement, but if
it does not, then the exception is thrown out of the function
3) throws declaration: Java requires that exceptions of type
Exception be declared as not handled using a "throws"
statement if they are not caught by a catch statement. This
is true even if the exception is thrown by a called function
rather than the function itself
4) finally always executes
know the different Java exception classes and what they do
1) Throwable--top-level exception class
2) Error--unrecoverable hardware errors
3) Exception--for user-defined exceptions--these are checked
by Java and must either be caught or declared unhandled
4) RuntimeException--the one type of Exception object that does
not have to be caught or declared unhandled
Graphical User Interfaces/Event Programming
1) Event Programming versus Procedural Programming
a) external versus internal control
b) distributed versus centralized-control
c) need for immediate feedback
d) input comes from events rather than console/files
e) output is graphics rather than console output/files
2) Presentation and Behavioral Components
3) Widget: A small, interactive, application-independent object that
either 1) performs some editing or input task, or
2) displays application state information or describes the input task
a) Types of widgets: know when it's appropriate to use the most common
types of widgets--radio buttons, check boxes, menus, sliders, spinners,
text boxes
i) provide informative displays
ii) allow user to enter one or more choices from a set of choices
iii) allow user to enter a number
iv) allow user to enter a text string
v) containers that organize/layout collections of widgets
b) Design Considerations
i) Acquire/Release of screen space to minimize footprint
ii) Enable/Disable: Typically gray out disabled widgets rather than removing
them so users always know where to look for them
iii) Active/Inactive: Always provide feedback when a widget is active
iv) Final Feedback: Always provide final feedback when a widget becomes
inactive so user sees final result and knows that the interaction is
finished