1. Chapter 1: Declaration, Access Control
    1. Identifier/JavaBeans
      1. Legal Identifiers: start with letter, $, _
      2. Keywords
      3. Sun's Java Code Conventions
        1. Class Name
        2. Method
        3. Variable
        4. Constant
      4. JavaBeans Standards
        1. get/set method, public
        2. boolean: is/get
        3. event/listener, addActionListener()
    2. Class Declaration
      1. Source File
        1. one public class per source file
        2. comments are anywhere
        3. public class name matches the file name
        4. package should before import
      2. Modifier
        1. Access: public, protected, private, default(package level)
        2. Non-Access: strictfp, final, abstract
          1. strictfp: conform to IEEE 754 floating point
          2. final: cannot be subclassed, java.lang.String
          3. abstract: can never be instantiated, is to be extended
          4. cannot combine these two modifier
    3. Interface Declaration
      1. Methods are implictly public and abstract
      2. Method cannot be static, final, strictfp or native
      3. Variables defined must be public, static and final
      4. Extends from 1 or more interfaces, not implements
      5. Cannot extend anything but interface
    4. Class Member
      1. Access modifier
        1. public: all other classes, regardless of the package they belong to, can access
        2. private: only the class which private member is declared
        3. protected/default
          1. subclass can see protected member only through inheritance
      2. Local variables
      3. Nonaccess member modifier
        1. final method
        2. final arguments
        3. abstract method
        4. synchronized method
        5. native method
        6. strictfp method
        7. variable argument list method
        8. Constractor
        9. variable
          1. primitive
          2. range
          3. reference
          4. local variable: always on the stack, rather than a heap
        10. enum
          1. cannot declare enum in a method
          2. neither String nor int
          3. special kind of class
          4. outside class must NOT static, final, abstract, protected or private
          5. ; is optional
    5. Wrong subject: 6, 8 and 9
      1. wrong again: 8
  2. Chapter 2: Object Orientation
    1. Topic
    2. Is-A
      1. Cannot extend more than one class
    3. Has-A
    4. Overriding
      1. Argument list should exactly match
      2. Return type should the same as or a subtype of
      3. Access level can't be more restrictive
      4. Can throw runtime exception
      5. Cannot throw checked exception
      6. Can throw narrower/fewer exceptions
      7. Cannot override final/static method
    5. Overloading
      1. must change the argument list
      2. can change the return type
      3. can change the access modifier
      4. can declare new/broader checked exception
    6. Reference Casting
      1. downcasting
      2. upcasting
    7. Implement interface
      1. A class can implement more than one interface
      2. interface self extend another interface
    8. Return Type
      1. Covariant returns in overriding return type which can be a sub class
      2. Return value
    9. Constructor and Instantiation
      1. every class MUST have a constructor
      2. Constructor Chaining
        1. Horse h = new Horse()
          1. Animal()
          2. Object()
      3. Rules
        1. any access modifier
        2. match the class name
        3. no return type
        4. same name method doesn't make it constructor
        5. default constructor will be automatically generated if no constructor was typed
        6. default constructor ALWAYS a no-arg constructor
        7. once one constructor is typed, no default will be generated
        8. every constructor first either call this() or super()
        9. cannot call directly the constructor
        10. abstract has while interface hasn't
      4. default constructor
        1. same access modifier as the class
    10. Static variables & Method
      1. static method cannot access a non-static variable
      2. static method cannot access a non-static method
      3. static method cannot be overridden
    11. Cohesion
      1. The degree to which methods in a class are related and work together to provide well-bounded behaviour
  3. Chapter 3: Assignments
    1. Literals Values
      1. 'c', false, 23.3232
      2. int
        1. decimal
          1. no prefix
        2. octal
          1. place 0 in front of the number
        3. hexadecimal
          1. Ox
        4. long: place a suffix L/l
      3. floating-point
        1. suffix F/f/D/d
      4. boolean
      5. character
        1. unicode:\u
        2. 16bit: 65535=2^16-1
      6. String
    2. Assignments
      1. primitive casting
        1. narrowing a primitive truncates the high order bits
      2. variable scope
      3. floating-point implicitly doubles
      4. literal integers are implicitly ints
    3. Uninitialized / Unassigned
      1. instance variable
        1. object reference: null
        2. byte, short, int, long: 0
        3. float, double : 0.0
        4. boolean: false
        5. char : '\u0000'
        6. array
      2. local
        1. primitive
        2. object
        3. always MUST be initialized or a compiler error
      3. assign reference to another
        1. copy,bit pattern
    4. Passing Object Reference Variable
      1. a copy of the reference variable
      2. pass-by-value sematics
    5. Array
      1. declare
      2. construct
        1. one dimension
        2. mulitidimensional
        3. anonymous array
          1. new int[] {1,2,3,4}
      3. assignment
        1. primitive
        2. object reference
          1. IS-A
    6. Initialization block
      1. static init
      2. instance init
        1. after super-constructor
        2. before the constructor
      3. can be more than one
      4. run in order --> top-down
    7. Wrapper
      1. Boolean:boolean
      2. Byte:byte
      3. Character:char
      4. Double:double
      5. Float:float
      6. Integer:int
      7. Long:long
      8. Short:short
      9. utitilies
        1. valueOf()
          1. take a string return a wrapped object, throw NumberFormatException
        2. parseXXX()
          1. take a string return primitive, throw NumberFormatException
        3. xxxValue()
          1. no argument return primitive
      10. autoboxing
        1. ==
          1. Boolean
          2. Byte
          3. Character from \u0000 to \u007f
          4. Short/Integer from -128 to 127
          5. ALWAYS be == when their primitive values are the same
        2. condition
          1. wherever u can normally use a primitive or wrapped object
      11. immutable
    8. Overloading
      1. boxing
        1. widening
        2. autoboxing
      2. var-args
        1. widening
        2. var-args
      3. boxing vs var-args
        1. var-args is more loose
          1. so boxing beats var-args
      4. widening reference variables
      5. widening + boxing
        1. CANNOT widen then box
        2. CAN box then widen
    9. Garbage Collection
      1. heap
      2. when
        1. can ask but no guarantees
      3. how
        1. mark/sweep algorithm
        2. reference counting
        3. when an object is eligible for gc
          1. nulling
          2. reassign
          3. isolaating
      4. forcing gc
        1. request: System.gc()
          1. java.lang.System
          2. java.lang.Runtime
      5. finalize()
        1. before object is deleted by gc
        2. will be called only once(at most) by gc
        3. call finalize() can actually result in saving an object from deletion
    10. Wrong Exercises: 1, 3, 5, 8, 10, 11, 12 and 14
      1. wrong again: 11, 12
  4. Chapter 4: Operators
    1. Assignment
      1. primitive
        1. size matters
        2. implicit casting
        3. explicit casting
      2. reference
      3. compound assignment
    2. Relational
      1. > >= < <=
      2. == !=
        1. primitive
        2. reference
        3. enum
      3. instanceof
    3. Arithmetic
      1. + - * /
      2. remainder: %
      3. String concatenation: +
      4. increment/decrement: ++ --
    4. Conditional
      1. ?:
    5. Logical
      1. bitwise
      2. short-circuit
        1. &&
        2. ||
      3. logical (not short-circuit)
        1. &
        2. |
        3. ^ (XOR)
        4. !
    6. Wrong Exercises: 3, 6 and 8
      1. wrong again: N/A
  5. Chapter 5: Flow Control, Exceptions, Assertions
    1. Flow Control
      1. if else
      2. switch
        1. char, byte, short, int, enum
        2. case: compile time constant
          1. same type as switch expression
          2. only check for equality
          3. won't allow more than one case using the same value
          4. wrapped variables aren't considered as compile time constant
        3. break
          1. case evaluated top-down
          2. first match case is the execution entry point
          3. ends untils break found or switch statement ends
        4. default
      3. while
      4. do while
      5. for
      6. ehanced for
        1. for(declaration: expression)
      7. break, continue
        1. unlabeled
        2. labeled
    2. Exception
      1. try...catch
      2. finally
        1. even there's a return in try block
      3. define
        1. subclass of java.lang.Exception
      4. Hierarchy
        1. Object
          1. Throwable
          2. Error
          3. ...
          4. Exception
          5. RuntimeException
          6. ...
          7. ...
      5. handling
        1. 8
      6. match
        1. first looking at the catch clauses for the type
        2. if can't find, search the supertype of the exceptions
      7. declaration
        1. method must either handle all checked exceptions by catch clause, or
        2. list each unhandled checked exception as thrown exception
        3. RuntimeException and Error are exempt
      8. rethrowing
      9. override
        1. can throw same exception
        2. narrower exception
        3. no exception
        4. runtime exception
      10. Common Exception and Error
        1. NullPointerException
        2. NumberFormatException
        3. ...
        4. StackOverflowError
        5. AssertionError
        6. ...
    3. Assertion
      1. test ur assumptions during development
      2. but evaporates when deployed
      3. assert (boolean)[:string]
      4. enable assertions
        1. compile
          1. 1.4
          2. javac -source 1.4 \w+\.java
          3. 5.0
        2. running
          1. java -ea
          2. java -enableassertion
        3. disable
          1. java -da
          2. java -disableassertion
        4. selective enabling and disabling
          1. java -ea -da:<packagename|classname>
      5. appropriately use
        1. NOT use to validate arguments to a public method
        2. DO use to validate arguments to a private
        3. NOT validate command-line argument
        4. DO use wherever u consider are never, ever gonna happen
        5. NOT use that can cause side-effect
    4. Wrong Exercises: 3, 7, 8, 13 and 15
      1. wrong again: 3, 8, 13
  6. Chapter 6: Strings, I/O, Formatting, Parsing
    1. String
      1. Immutable
      2. charAt, concat, equalsIgnoreCase, etc.
      3. StringBuffer/StringBuilder
    2. I/O
      1. File
      2. FileReader
      3. BufferedReader
      4. FileWriter
      5. BufferedWriter
      6. PrintWriter
      7. wrap
      8. delete() cannot purge a non-empty directory
      9. renameTo() can operate directory even if it's not empty
    3. Serialization
      1. ObjectOutput/InputStream
      2. Object Graphs
        1. all field need to be serializable
        2. transient
        3. private void writeObject
        4. private void readObject
      3. Inheritance
        1. Superclass is NOT serializeable
      4. statics
    4. Dates, Numbers, Currency
      1. java.util.Date
        1. 1 trillion milliseconds = 31 2/3 years
      2. Calendar
        1. abstract class
        2. static factory method
        3. add()
        4. roll()
      3. DateFormat
        1. abstract class
        2. overloaded factory method
          1. getInstance()
          2. getDateInstance()
        3. format()
        4. parse()
          1. ParseException
      4. Locale
        1. Locale(String language)
        2. Locale(String language, String country)
      5. NumberFormat
        1. abstract
        2. overloaded static factory method
          1. getInstance()
          2. getCurrencyInstance()
      6. Currency
        1. getInstance
    5. Parsing, Tokenizing, Formatting
      1. Regex
        1. metacharacters
        2. quantifiers
        3. escape character
      2. Tokenizing
        1. split()
      3. Formatting
        1. %[arg_index$][flags][width][.precision]convertion
        2. arg_index
        3. flags
          1. -: left justify
          2. +: include a sign
          3. 0: pad with zeros
          4. ;: use locale-specifc separators
          5. (: enclose negative number in ()
        4. width
        5. precision
        6. conversion
          1. b: boolean
          2. return true for any non-null or non-boolean argument
          3. c: char
          4. d: integer
          5. f: floating point
          6. s: string
  7. Chapter 7: Generic & Collections
    1. Class methods
      1. toString()
      2. equals()
        1. reflexive
        2. symmetric
        3. transitive
        4. consitent
      3. hashCode()
        1. a.equals(b) -> a.hashCode()==b.hashCode()
        2. a.hashCode()!=b.hashCode() -> a.equals(b) == false
        3. transient variable may cause fail
      4. public method
    2. Collections
      1. <<interface>> java.util.Collection
        1. <<interface>>List
          1. ArrayList
          2. Vector
          3. LinkedList
          4. get(int index), indexOf(int index), add(int index, Object obj), etc.
          5. Iterator: hasNext(), next()
        2. <<interface>> Set
          1. SortedSet
          2. HashSet
          3. LinkedHashSet
          4. TreeSet
        3. <<interface>> Queue
          1. PriorityQueue
          2. offer(), poll(), peak()
        4. toArray()
      2. <<interface>>Map
        1. SortedMap
        2. HashMap
        3. Hashtable
        4. TreeMap
        5. LinkedHashMap
      3. Ordered & Sorted
        1. alphabetically
        2. ascending
        3. implements Comparable
        4. Comparator
      4. utility
        1. java.util.Collections
          1. sort()
          2. Comparable: compareTo()
          3. Comparator:compare()
          4. binarySearch()
          5. void reverse()
          6. reverseOrder()
          7. return a Comparator that sorts in reverse
        2. java.util.Arrays
          1. binarySearch()
          2. sort()
          3. asList(T[])
    3. Generic
      1. MUST be the exactly type in generic when initialize a generic collection
      2. Methods
        1. method(List<? extends Base> parameter)
        2. method(List<? super Child> parameter)
        3. method(List<?> list)
        4. method(List<Object> list)
        5. ? means many possibilities
        6. only for reference declarations
        7. different
      3. Class
        1. class SomeGeneric<T>
        2. class SomeGeneric<T extends Base>
      4. http://www.javaprepare.com/notes/collectn.html
      5. Generic Methods
        1. public <T> void method(T t)
        2. public <T extends Number> void method(T t)
  8. Chapter 8: Inner Class
    1. inner class
      1. Regular
        1. Static
        2. Method-local
        3. Anonymous
      2. Instantiating
        1. Within the outer class
        2. Outside the outer class instance
      3. Reference
        1. this
        2. Outer.this
        3. Modifier
          1. final
          2. abstract
          3. public
          4. private
          5. protected
          6. static
          7. strictfp
    2. method-local inner class
      1. can be ONLY instantiated only with the method
      2. cannot use the local variable of the method
      3. unless the local variables are final
      4. can access enclosing class private member
    3. anonymous inner class
      1. Plain-old
        1. Flavor I
          1. subclass
        2. Flavor II
          1. implementer
      2. Argument-defined
        1. take care of the semicolon
    4. static nested class
      1. not an inner class
      2. requires both outer and nested class names
      3. cannot access non-static members
  9. Chapter 9: Threads
    1. define
      1. Extends java.lang.Thread
        1. constructor
          1. Thread()
          2. Thread(Runnable target)
          3. Thread(Runnable target, String name)
          4. Thread(String name)
      2. Implements Runnable
      3. Thread class implements Runnable interface
    2. Starting Thread
      1. t.start()
      2. A thread done when its target run() completes
      3. Once it has been started, it can never be started again
    3. Scheduler
    4. States
      1. New
        1. before start() invoked, not alive
      2. Runnable
      3. Running
      4. Waiting / blocked / sleeping
      5. Dead
    5. Priorities
      1. 1~10
      2. if not explicitly set, the same as the created thread
      3. NEVER rely on it to guarantee the correctness
      4. yield()
        1. allow other threads of the same priority to get their turn
    6. Synchronization
      1. methods and blocks
      2. sleep doesn't release the lock
      3. each object has just one lock
      4. static method can be synchronized
    7. When cannot get lock
      1. static synchronized always block each other
      2. method and lock status
    8. methods that access changeable fields need to be synchronized
    9. Thread-Safe Class
      1. Collections.synchronizedList()
    10. Deadlock
    11. Interaction
      1. wait(), notify(), notifyAll()
        1. belong to java.lang.Object
      2. for a thread to call wait(), notify(), it has to acquire the lock
      3. wait() gives up the lock immediately
    12. Wrong Exercise:2, 5, 12, 13, 16 and 17
      1. wrong again: 12, 16, 17
  10. Chapter 10: Development
    1. compiling
      1. javac [option] [source files]
        1. -d
          1. if dest dir not existed, a compiler error occurs
          2. would create the directory
    2. launching
      1. java [options] class [args]
        1. system properties
          1. -Da=b
    3. search other classes
      1. first, standard J2SE
      2. then, classpath
      3. packages
      4. relative/absolute path
    4. jar files
      1. jar -cf
      2. .../jre/lib/ext
    5. static imports
      1. import static java.lang.System.out
  11. SCJP Sun Certified Programmer for Java 5 Study Guide (Exam 310-055).chm
  12. SCJP_guide_exercise.txt