20-ECES-694-001

Advanced Programming Techniques

Object Oriented Programming, Graphics, Threads, Streams, Animation, Networking, File Manipulation, Reflection

News
   Please use amazon.com to order the textbook or use the online version (10 Mar 08)
   Checkout this article for Java performance tips (thanks Adam - 27 Mar 07)
   Help for Windows addiction sufferers (4 May 07)
   JavaSound Source
   Alternative email for Exam: francojv2001@yahoo.com
 
Credits
   Copyright notices
 
Documentation
    Java Language Tutorial
    Main Java Documentation Page
    Java Platform 1.5.0 API Specification - Very useful page
    FAQs
    Data Base Package (java.sql)
 
Syllabus
   HTML version     
 
Questions (most from previous quarters)
   1.   What happens when a Thread is interrupted by an InterruptedException - where is the exception caught?
   2.   Suppose class C extends class A and implements interface B. Can C implement a method that has the same signature in both A and B?
   3.   Can a class implement two interfaces if they specify the same function?
   4.   I don't get it. How does "interface" help provide services from multiple classes?
   5.   If a package imports a class A and your code imports the package, is the class A automatically imported by your code?
   6.   Does a user-created class inherit from class Object even if it does not extend from Object directly?
   7.   Can one use reflection classes to interpret objects read from file using readObject from an ObjectInputStream without type casting them?
   8.   Name some java supported protocols.
   9.   How does one create an image from an array?
   10.   Need to implement an interface method that is inherited from super class?
   11.   Can super invoke the parent's inherited method?
   12.   What error do you get when referencing an uninstantiated array?
   13.   Can you add buttons to a panel after init()?
   14.   Can reference to buttons, etc., be obtained on the fly.
   15.   Wow! Can you show me more?
   16.   If two classes implement ActionListener (say), whose actionPerformed will be invoked?
   17.   How do I set my PATH variable on helios to run and compile java code?
   18.   How do I run an applet?
   19.   What about an application version of the seconds timer?
   20.   Can you show an example of notify not notifying threads in a different monitor?
   21.   Besides the notify variants, how can I wake up a Java thread?
   22.   Can you tell me what Java's thread running policy is, anyway?
   23.   Can I access a private field using setDouble()?
Can I use getBoolean() on a double field?
   24.   Is it possible for an interfaced service provider to broadcast responses to several clients?
   25.   What's the deal with those * symbols in import statements?
   26.   Can I return to a statement after one in which an Exception is raised?
   27.   What's the deal on finally?
   28.   Can interactions between scrollbars in this be stopped using synchronized?
   29.   Why not double buffer images like crazy instead of clipping?
   30.   What's the deal on multiple threads in the Checkers game?
   31.   How can you change memory dynamically in Java?
   32.   Can you reimplement the garbage collector?
   33.   Can java garbage collect C code from JNI?
 
Midterm, 2008
   Exam    How to move a checker    client    Server source    Network Examples
 
2008 Midterm Grades
   Checkers
 
Lecture Notes
    C++ to Java (postscript)      (PDF)      Source files
    Preliminary Code - Prepare for Applet Intro
    Applet Intro
    Layout Options
    Layout Questions
    Exceptions
    Exceptions for program control - declarative programming in Java
    Packages and Visibility - short story
    Packages and Visibility - full story
    Interface - Multiple Inheritance - 1
    Interface - Multiple Inheritance - 2
    Interface - Multiple Inheritance - 3
        Digression: What is going on here?
    Threads     synchronize-notify-wait descriptions     synchronize-notify-wait examples
        Digression: Illustrate producer/consumer with monitor
                Source code for above
        Digression: Sample Exam Question?
        Digression: Examples of Data Driven Computation
        Digression: Difference between forks and threads
    Timers
    Threads and Animation
    Fonts
    Colors and Drawing
    More Threads and AWT
    Dialog Boxes
    Utility Classes
    Input/Output Streams
    Files (sample java.policy file)
    Networking
    RMI
    JNI
    Runtime
    Security
    SecurityManager
    JDBC (modified from javasoft.com)
    Swing
    Reflection
 
Project
    Use ssh to tunnel to project machines
    Description
    Protocol (See RMI section)
   A Player
   Handshake demo    RSA description    Hash description    Karn description    (as shown in Lecture)
   BigIntegerTest.java    SecureRandomTest.java    MessageDigestTest.java    (as shown in Lecture)
   Useful Docs:
       Project Classes
       Player Classes
           KarnBufferedReader
           KarnPrintWriter
           PlayerCertificate
           PubRSA
           CertRemote
           RSA
       serialized form
   Useful Code:
       CertRemoteImpl_Stub.class
       rmi_test.java
       RSA.java
       PubRSA.java
       CertRemote.java
       PlayerCertificate.java
       KarnBufferedReader.java
       KarnPrintWriter.java
 
    Tournament Dates and Submitting your work
    Possible first login
    Do you know where your cookie is?
    Practice Tournament Standings (helios:8180)
    Final Tournament Standings (helios:8180)
 
    Explain Secure Hash Algorithm (SHA-1)
    Explain Karn Encryption
 
    Sample session log
    Sample sniffer session - Watch Out!!! Encryt!!!
 
    A Packet Sniffer - for Linux - Amuse yourself with this one
    You may need these libraries for the sniffer
 
    Game Parameters for the Final Tournament
    Game Parameters for the Practice Tournaments
    Difference of above two files
 
Assignments
    1: Assignment Number One - Warm up, translate C++ logical analyzer to Java
    2: Assignment Number Two - Declarative Style
    3: Assignment Number Three - Streams, Threads, and the Stock Market
    4: Assignment Number Four - Instant Messenger Client and Server
Reasonable solutions to the homework
Assignment 1:   
       Main classes:     Gate.java Logic.java Interconnect.java    Not.java
Nand.java Nor.java Queue.java Connect.java
Higher Level Classes:    Counter.java     JKFF.java     RSFF.java Circuit.java
XOR.java     Adder.java    
---------------------------------------------------------------------------------------------------------------------------------
Assignment 2:   
       Exceptions for termination     backtracking
Basic classes: Variable Choose Puzzle
Constraint classes:    Contraints Expressions
Examples of use: Kalotan Color Europe     Logic Puzzle
Applets: Kalotan Color Europe    Logic Puzzle
---------------------------------------------------------------------------------------------------------------------------------
Assignment 3:   
       Stream Classes: Stream.java GateStream.java CollectorStream.java
Basic classes: IntObject.java ConnectEntry.java
Example of use: ConnectionRefusedException.java    Consumer.java Producer.java
Subscriber.java Investor.java Maintainer.java
Example of use: TestConsumer.java TestProducer.java    TestGate.java
Example of use:    TestCollector.java
---------------------------------------------------------------------------------------------------------------------------------
Assignment 4:   
       All Classes:    Server.java    HostIP.java (Client)
  
2004 Midterm Exam Reasonable Solution (Exam)
   Stream.java     ConnectionRefusedException.java (optional)     ConnectEntry.java (optional)
   The above may be tested using the following classes
    Test1.java    PC1.java     Consumer1.java     Producer1.java     Applet
    Test2.java    PC2.java     Consumer2.java     Producer2.java     Applet
 
   One student's response: 100 percenter
 
2003 Midterm Takehome Exam Reasonable Solution (Exam Option 1     Exam Option 2)
   Sample solution to #2:    LevyChess.java     Chess.java     Applet
 
2002 Midterm Exam Reasonable Solution (Exam)
   Question 1: no output, program terminates soon after execution.
   Question 2: no output, program does not terminate.
   Question 3: increasing integers are printed, never stops (unless...).
 
2000 Midterm Exam Reasonable Solution (Exam)
    PipeStream Class
    Merge, Times, Successor: tests
 
1999 Midterm Exam Sample Solutions (Morning Exam      Evening Exam)
   Morning 1: Gather
   Morning 2: Multiply
   Evening 1: Streams
   Evening 2: Inet Snoop      Kuppili's Solution


The Following Are Some Examples
For Lecture Notes, See The Section Above

Hello World
   Simple Hello World      Applet Source    Applet
   Rotating Colors      Applet Source    Applet
       
Basic Graphic Objects
   Fonts    Frame Source    Applet Source    Applet
   Centered Text    Frame Source    Applet Source    Applet
   Buttons & Panels    Frame Source    Applet Source    Applet
   Grid Layout    Frame Source    Applet Source    Applet
   Border Layout    Frame Source    Applet Source    Applet
   Scroll Bars    Frame Source    Applet Source    Applet
   Text Fields    Frame Source    Applet Source    Applet
   Text Areas    Frame Source    Applet Source    Applet
   Choice Boxes    Frame Source    Applet Source    Applet
   Frames    Frame Source    Applet Source    Applet
   More Frames    Frame Source    Applet Source    Applet
   Menus    Frame Source    Applet Source    Applet
   Dialog Boxes    Frame Source    Applet Source    Applet
   File Selector    Frame Source    Applet Source    Applet
       
       
Threads
   Thread Priority    Frame Source    Applet Source    Applet
   Synchronization    Frame Source    Applet Source    Applet
       
       
Graphics Support
   Shapes & Parameters    Frame Source    Applet Source    Applet
   Rotate Colors: Threads    Frame Source    Applet Source    Applet
   Override Backgrnd Draw    Frame Source    Applet Source    Applet
   Simple Animation    Frame Source    Applet Source    Applet
   Animation with Clipping    Frame Source    Applet Source    Applet
   Double Buffering    Frame Source    Applet Source    Applet
       
       
Nifty Tricks
   Type Conversions    Frame Source    Applet Source    Applet
   Fonts Galore    Frame Source    Applet Source    Applet
       
       
Use of interface
   Simple Examples    Java Source    
   Changing Functions    Frame Source    Applet Source    Applet
       
       
Streams and interface
   A Stream Class    Java Source      How it works
   Example: Successor    Java Source    
   Example: Times    Java Source    
   Example: Merge    Java Source    
   Example: Hamming    Java Source    Applet Source    Applet
       
       
Streams and Threads
   A Stream Class    Java Source      How it works
   Example: Successor    Java Source      Applet
   Example: Times    Java Source      Applet
   Example: Merge    Java Source      Applet
   Example: Hamming    Java Source    Comb. Applet    Applet
       
       
   Alternative (Channels)      Applet Source    Applet
       
       
   Alternative (No cigar)      Applet Source  
       
       
Files
   Reading and Writing    Frame Source    Applet Source    Applet
   Misc. File Methods    Frame Source    Applet Source  
       
       
Timers
   Generating an event
   after specified period
   Frame Source    Applet Source    Applet
       
       
Clients and Servers
   File (Proxy) Server    Java Source    C Source    How it works
   Interface for above    Java Source    Sample use    Applet (sample use)
   Echo Server    Server Source    Client Source    C/S Applet (simulation)
   Proxy Server    Server Source    Client Source    Applet
   Web (http) Server    Java Source    Frame Source    How it works
   Quote Generator
   Using File Server
   Frame Source    Applet Source    Applet
       
Applications
   Calculator      
   TextFields, Buttons      Applet Source    Applet
   Encryption/Decryption      
   TextFields, Buttons      Applet Source    Applet
   Create, Move Objects      
   Mouse, Drawing,
   Double Buffering
     Applet Source    Applet
   Gas Simulation      
   Animation, Threads,
   Mouse
     Applet Source    Applet
   Pool Table      
   Animation, Threads      Applet Source    Applet
   Mortgage Calculator      
   AWT, Graphics    1.0.2 Source    1.1 Source    Applet