1 / 25

Text Book: Java Program Design 1.5, by James Cohoon & Jack D.

Course Outline - ISM4234 Intro. To OOP Concepts and Java Applications Intro. to IDE tools: NetBean IDE 3.6. Text Book: Java Program Design 1.5, by James Cohoon & Jack D. McGraw Hill 2004, ISBN 0-07-304467-9. References: Big Java, Programming and Practice,

ramona
Download Presentation

Text Book: Java Program Design 1.5, by James Cohoon & Jack D.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Course Outline - ISM4234 Intro. To OOP Concepts and Java Applications Intro. to IDE tools: NetBean IDE 3.6 Text Book: Java Program Design 1.5, by James Cohoon & Jack D. McGraw Hill 2004, ISBN 0-07-304467-9. References: Big Java, Programming and Practice, by Cay Horstmann, John Wiley & Sons, Inc., ISBN 0471-40248-6. The Essential JAVA Class Reference For Programmers By Brian Durney, Prentice Hall, ISBN 0-13-093385-6 Tutorial for Sun ONE Studio 4, by Y. Liang, Prentice Hall 2002. ISBN 0-13-141080-6; or Forte for Java, Community Edition, Getting Started Guide, http://forte.sun.com/ffj/documentation/release3/getstartedce30.pdf) Week 1 05/16/2006 Course ISM4234-004 Dr. Simon Qiu

  2. Course Outline – OOP with Java • Why Java ? Object Oriented; Portable; Multithreaded; Robust & high Performance • Introduce the fundamentals of Object-Oriented Programming. • Building Java applications, applets and utilizing Java 2 API. • Introducing the principles of Object-oriented programming – Classes – Data type, Methods, Scope; Inheritance; Polymorphism; Interfaces. Information hiding, Arrays; Strings; Files and Streams; Graphics and Multimedia; Exception handling; Multithreading; Database connectivity. • Control Structures; Common Algorithms; Recursion; Collections. • Homework formatting • Source code (*.java) and Compiled executable file (*.class) and other source files • Screen captured file (show your input and output as results) Week 1 05/16/2006 Course ISM4234-004 Dr. Simon Qiu

  3. Computer System Review • Java Environment • Java Class Libraries (API) • Object-Oriented Analysis and Design • Tour of the Chapters of the Book Week 1 05/16/2006 Course ISM4234-004 Dr. Simon Qiu

  4. Java Environment Java Translation and Execution Phase2: Compile the source code file into welcome.class by using javac welcome.java ( to a target program) Java source code Java bytecode Phase1: Editing a source file - welcome.java Java compiler Java interpreter Bytecode compiler Phase3: Class loading into memory for - Application: java welcome; (translation & execution) Applet: appletviewer welcome (Web Browser) Machine code Phase4: The bytecodes loaded from internet or network are verified. Phase5: The bytecode compiler interprets the verified bytecode into machine code one at a time and as an executable program.

  5. Java Class Libraries • Way to learn Java programming: • writing your own classes; • using classes in extensive Java class libraries (Java API) • Java Class Libraries are known as Java API (Application Programming Interfaces) • A class library is a collection of classes used for developing program • Java programs consist of classes • Classes consist of methods that perform tasks and return information • Java standard class library that is part of Java development environment (for example: the System class and the String class) • Other class libraries can be obtained through third party vendors, or you can create them yourself

  6. Object-Oriented Analysis and Design (OOAD) • OOP Object-oriented Programming such as Java • C programmers concentrate on writing functions. • Java programmers concentrate on creating their own user-defined types – classes and components. • OOAD • involves analyzing and designing your system from an object-oriented point of view. • OOD Object-oriented Design • provides a more natural and intuitive way to views the design process • by modeling real-world objects, their attributes, their behavior • OOD encapsulates data (attributes and functions (behavior into objects)

  7. Tour of the Chapters of the Book • Chapter 1Background • Chapter 2 Java Basics • Chapter 3 Using Objects • Chapter 4 Being Classy • Chapter 5 Decisions • Chapter 6 Iteration • Graphics Interlude I: GUI-Based Programming • Chapter 7 Programming with Methods & Classes • Chapter 8 Array and Collections • Chapter 9 Inheritance and Polymorphism • Graphics Interlude II: GUI-Based Programming • Chapter 10 Exceptions • Chapter 11 Recursive Problem Solving • Chapter 12 Threads • Chapter 13 Testing and Debugging

  8. Development Environments • There are many development environments which develop Java software: • Sun Java Software Development Kit (SDK) • Sun One Studio (Forte) and NetBeans 3.6/4.0 • Borland JBuilder • MetroWork CodeWarrior • Microsoft Visual J++ • Symantec Café • IBM VisualAge for Java • Though the details of these environments differ, the basic compilation and execution process is essentially the same

  9. Java Program Structure • In the Java programming language: • Java created in 1995 by SUN has become a quite popular object-oriented language • A program is made up of one or more classes • A class contains one or more methods • A method contains program statements • These terms will be explored in detail throughout the course • A Java application always contains a method called main • A Java applet always contains a method called init or start or paintto start a program without main

  10. Java Program Structure // comments about the class public class MyProgram { } class header class body Comments can be added almost anywhere

  11. Java Program Structure // comments about the class public class MyAppProgram { } // comments about the method public static void main (String[] args) { } method body method header public class MyAppletProgram extends JApplet { } // comments about the method public void init ( ) { } method body

  12. Identifiers • Identifiers are user-defined names for class, data and methods. They are the words a programmer uses in a program • An Identifier can be made up of letters, digits, the underscore character (_), and the dollar sign, such as: number, number2m amount_of_sale, $amount. • The following Identifiers are not valid: 1number (cannot begin with a digit), amount of sale, &amount • Java is case sensitive, therefore Total and total are different identifiers • Sometimes we choose Identifiers ourselves when writing a program (such as Lincoln) • Sometimes we are using another programmer's code, so we use the Identifiers that they chose (such as println) • Often we use special Identifiers called reserved words that already have a predefined meaning in the language • A reserved word cannot be used in any other way

  13. Reserved Words The Java reserved words: abstract boolean break byte byvalue case cast catch char class const continue default do double else extends false final finally float for future generic goto if implements import inner instanceof int interface long native new null synchronized this throw throws transient true try var void volatile while operator outer package private protected public rest return short static super switch

  14. White Space • Spaces, blank lines, and tabs are collectively called white space • White space is used to separate words and symbols in a program • Extra white space is ignored • A valid Java program can be formatted many different ways • Programs should be formatted to enhance readability, using consistent indentation

  15. Syntax and Semantics • The syntax rules of a language define how we can put symbols, reserved words, and identifiers together to make a valid program • The semantics of a program statement define what that statement means (its purpose or role in a program) • A program that is syntactically correct is not necessarily logically (semantically) correct • A program will always do what we tell it to do, not what we meant to tell it to do

  16. Errors • A program can have three types of errors • The compiler will find problems with syntax and other basic issues (compile-time errors) • If compile-time errors exist, an executable version of the program is not created • A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run-time errors) • A program may run, but produce incorrect results (logical errors)

  17. Intro. to Java Applications Writing A First Program in Java – Welcome1.java Compiling the Source File into - Welcom1.class Execute The Compiled Program Week 1 05/16/2006 Course ISM4234-004 Dr. Simon Qiu

  18. Writing A First Program // Save the following code to file in C:\temp\myjava\Welcome1.java public class Welcome1 { // main method begins execution of Java application public static void main( String args[] ) { System.out.println( "Welcome to Java Programming!" ); } // end method main } // end class Welcome1

  19. Compiling the Source File (Download ftp://itom.fau.edu/sqiu/Docs/HowToJavaCompiler.doc] • Set path = … ; c:\jdk1.4\bin (to ensure system can find Java tools) where the compiler javac.exe in (for window 95/98: edit autoexec.bat file under root of c:\) • C:\> cd c:\temp\myjava • Compile your newly created java file: C:\temp\myjava > javac Welcome1.java Now, the compiled bytecode file Welcome1.class is created.

  20. Executing the Bytecode File • Load a dos window by running cmd.exe (or command.exe – win95/98) • C:\> cd c:\temp\myjava • Run the compiled file: C:\temp\myjava > java Welcome1

  21. Intro. to Java Applets Writing A First Applet Program in Java – WelcomeApplet.java Compiling the Source File into - WelcomApplet.class Executing Program trough a HTML file – WelcomApplet.html Week 1 05/16/2006 Course ISM4234-004 Dr. Simon Qiu

  22. Writing A First Applet // save the folloeing code to file WelcomeApplet.java - A first applet in Java. import java.awt.Graphics; // import class Graphics // Java extension packages import javax.swing.JApplet; // import class JApplet public class WelcomeApplet extends JApplet { // draw text on applet’s background public void paint( Graphics g ) { // call inherited version of method paint super.paint( g ); // draw a String at x-coordinate 25 and y-coordinate 25 g.drawString( "Welcome to Java Programming!", 25, 25 ); } // end method paint } // end class WelcomeApplet

  23. Compiling the Source File • Set path = … ; c:\jdk1.4\bin (to ensure system can find Java tools) where the compiler javac.exe is in (for window 95/98: edit autoexec.bat file under root of c:\) • C:\> cd c:\temp\myjava • Compile your newly created java file: C:\temp\myjava > javac WelcomeApplet.java Now, the compiled bytecode file WelcomeApplet.class is created.

  24. Executing the Bytecode File <html> <applet code = "WelcomeApplet.class" width = "300" height = "45"> </applet> </html> • Create a HTML file above – WelconApple.html To load the applet into a Web Browser (or using appletviewer) • Load a dos window by running cmd.exe C:\> cd c:\temp\myjava C:\temp\myjava > appletviewer WelcomeApplet

  25. Assignment 1 – Reading: Chapter 1-2 1-1. Follow the instruction of how to use Java compiler to install a java JDSK v.1.4.1 to your computer and test it. 1-2. Write and run a simple Java program that displays a greeting: “Welcome to Java World!” 1-3. Write and run a simple Applet program that displays a greeting: “Welcome to Java World!”

More Related