21 Days:   Wk1 . Wk1Ref . Applts . Swing . Grph . D13-14 . D15-21 . D22-28
  cc12:   Miscl . SQL . EJB . Vocab . (NotesHelp) . J2EE . Web
  misl:   21 Days(src) . Dictionary(foldoc) . Unicode . Tables . Print . html
  misl:   F.Allimant . Swing (J.H.University)

  Refererences and Links.

  Notes.

  DAY 15: Packages, Interfaces, and Other Class Features. (pg.381-416: 36 pages)
===Access [*]Q: Since, "Any variable declared without a modifier can be read or changed by any other class in the same package.", can only those classes change the variable? [No] (pg.383)
The Four Different Levels of Access Control
Visibility public protected default private
from same class yes yes yes yes
from any class in same package yes yes yes no
from any class outside the package yes no no no
from subclass in same package yes yes yes no
from subclass outside same package yes yes no no
- Default access methods and variables are not inherited to subclass, outside the package of the superclass. (pg.383) ===Abstract Classes and Mehtods (pg.392) - A class declared to be abstract will not be used make an instance of the class. - Only abstract classes can include abstract methods. - Abstract methods have no body. - If an abstract class's methods are all abstract, you are better off to use an interface. - An abstract class can have constructor methods. ===Packages (pg.393) - A package is a grouping of classes. - The classes from the java.lang package are automatically available without import. (pg.394) - Note: import makes packages and classes available, it does not change the size of your class. (pg.396) ===Interfaces (pg.399) - Interfaces (similar to abstract classes and methods (pg.393)) "...provide templates of behavior that other classes are expected to implement." (pg.399) - "a Java interface contains nothing but abstract method definitions and constants-- no instance variables and no method implementations". (pg.400) - Classes and interfaces have a lot in common. - It is not possible to create an instance of an interface.
  DAY 16: Error Handling and Security. (pg.417-441: 25 pages)
- Sample. try { ...Method(s) that may throw an exception(s) } catch (ExcpetionType e) { ...Handle the exception(s). } - Optional: After the catch, you can have a finally clause. finally { ...Code that absolutely must be done. } - "A subclass method cannot throw more exceptions than its superclass method." (pg.430) - Ballanced Perspective: Processs exections more, throw them less.
  DAY 17: Handling Data Through Java Streams. (pg.443-467: 25 pages)
===Introduction. (pg.443) - Java Streams makes it easy to do input and output to any source or destination. - This chapter deals with two types of Streams: . Byte Stream - handles bytes, integers and other simple data types. A byte can be from 0 to 255. . Character Stream - handles text files. (including web pages). - Both of these stream types are handled in a similar way. ===Using a Stream. (pg.444) - Input Stream. 1. Create an object associated with the data source, (such as a FileInputStream). 2. FileInputStream's read() method returns one byte from the stream. 3. Use close() when done with the stream. - Output Stream. 1. For example, BufferedWriter class can be used to create text files. 2. write() is the simplest way to output to the stream. 3. Use close() when done with the stream. ===Filtering a Stream. (pg.445) - A filter is a stream that modifies an existing stream. (like a dam in a creek). - Read or write useing the filter, instead of the origional stream. - The methods are the same with a filter, as they are with a stream. - It is legal to filter a filtered stream. ===Byte Streams. (pg.446) - All byte streams are subclasses of one of the two abstact classes, InputStream or OutputStream. - FileInputStream, FileOutputStream - byte streams for files. - DataInputStream, DataOutputStream - filtered byte stream for int and float etc. ===Filtering a Stream. (pg.450) - BufferedInputStream, BufferedOutputStream - Filter classes. ===Character Streams. (pg.458) - FileReader is a Character Stream Reader. - BufferedReader is a Filter. (pg.459) . Has a method named readLine() to read to CR and/or LF. . CR and LF will not be in the returned String object. . Returns "null if the end of the stream has been reached". (Sun Doc) - FileWriter is a Character Stream Writer. . "Has behavior to convert Unicode character codes to bytes." (21Days.pg.461) - BufferedWriter is a Filter. (pg.461) . Has a method named newLine(). ===Files and Filename Filters. (pg.462) - Rename files, etc.
  DAY 18: Object Serialization and Reflection. (pg.469-494: 26 pages)
===Introduction. - "An essential concept of object-oriented programming is the way it represents data. In an object-oriented language such as Java, an object represents two things:" - Behavior - instructions. - Attributes - data. - Three ways Java programs take advantage of encapsulating instructions and data: 1) Object Serialization. - read and write and object using Streams. 2) Reflection. - an object learns details of another object. 3) Remote Method Invocation. - query another object to investigate its features and call its methods. 1) OBJECT SERIALIZATION (2). (pg.470) = (old notes) - Related phrase: "a series of variables or objects". (lowerMiddle.pg.470) - Serial data is sent one item at a time. - Class "Serializable" has no methods. Only purpose to indicate its instances can be "stored and retrieved in serial form". (topMiddle.pg.471) - persistence - Ability of an object to exist and function outside its parent program. - transient modifier - Contents of a variable are not sent if its object is transmitted. (covered later in this chapter) = Object Output Streams. - ObjectOutputStream class is used to write an object. = (new notes) - [ ]Q: When transmitting an object, are the instructions transmitted? - The class of an object being readin must be in the same folder or a folder in the classpath. - In this example, "oi" is an instance of ObjectInputStream. myMessage mess = (myMessage)oi.readObject(); = Transient Variable. - // this variable's content is not sent if the object is transmitted. public transient int myInteger = 25; // example (pg.478) 2) Inspecting Classes and Methods with REFLECTION. (pg.478) (important for Trex) - Reflection. - an object learns details of another object. - Reflection is not needed in most aps. - Reflection usual uses: class browsers, debuggers, object serialization, JavaBeans, and other programs needing runtime access to classes. 3) REMOTE METHOD INVOCATION (RMI). (pg.485) - Used to call methods between server and client over a network. - A Java Interface is part of the implentation. - Multiple standard layers are implented on server and client to use remote objects. - Pass by reference of an array might not change array contents. (research further if needed) - Calls to objects with RMI should be a lot like that of local objects. - A lot of useful information in this chapter if RMI is needed.
  DAY 19: Communicating Across the Internet. (pg.495-522: 28 pages)
- Networking ===Opening Web Connections ===Opening a Stream over the Net - Sample: GetFile.java opens a text file with its URL and displays it. (p.501) ===Sockets - // Beyond URL. Socket sock = new Socket("myHost",portNum); sock.setSoTimeOut(40000); // 40 seconds DataInputStream in = new DataInputStream( new BufferedInputStream( sock.getInputStream())); // When done with the socket... sock.close(); ===Socket Servers (p.508) ===Implementing a Server (p.510)
  DAY 20: Working with JavaBeans. (pg.523-541: 19 pages)
- A JavaBean "is a software object that interacts with other objects according to a strict set of guidlines - the JavaBean Specification". (pg.523) - JavaBeans (beans), like objects, can be designed to be useful with programs other than the one it was written for. ===Reusable Software Components - "...any realistic long-term component technology must deal with both platform-dependancy and language-dependancy." - Persistence is a functionality from Java, that an object can "store and retrieve its internal state". - Persistence is done with serialization, which is part of Java. ===JavaBeans API - Some main component services in the JavaBeans API (each implemented as smaller APIs within the JavaBean API): (helpful to know these) - Graphical user interface merging - Introspection - Persistence - Application builder support - Event Handling ===Development Tools - An Integrated Development Enviromnet (IDE) should be used when working with JavaBeans. Sun provides a free kit called, JavaBeans Development Kit (BDK), but is only good enough for an intro to beans. ===WORKING WITH JAVABEANS - Encapsulation - Keeping a variable private and accessing it with a getter and setter. A good principle even when not building a bean. (pg.534) - "Hundreds of JavaBeans are available from Sun and other developers." Here are some suggested sites: - Click: The JavaBeans resource directory of the Java Applet Ratings Service. - Click: JavaWorld Magazine's Developer Tools Guide. (not found) - Click: Sun's JavaBeans home page. - (finished to pg.541.end_of_chapter) -------------------------------------- - EJB Tutorial - This tutorial teaches the EJB (Enterprise Java Beans) technology. - Enterprise JavaBeans (EJB) Article List - from JavaWorld. - Do you really need Enterprise JavaBeans? - EJB is not a one-size-fits-all solution. . Sun's J2EE Blueprints. - A First EJB Application - This section demonstrates a complete example application.
  DAY 21: Java Database Connectivity and Data Structures. (pg.543-570: 28 pages)
[ ]: MYSQL - An industry-standard language for creating, updating and, querying relational database management systems. (Day 21 (pg 544,545)/28, in 21 Days Book) ************************************************************************************* B19 - Teach Yourself Java 2 in 21 Days. 2nd ed. Lemay and Cadenhead. + 2001. *************************************************************************************
Java Home