university of central florida engineering data structures
play

University of Central Florida Engineering Data Structures EEL 4851 - PDF document

University of Central Florida Engineering Data Structures EEL 4851 JAVA LABORATORY MANUAL (Revised edition, 2002) Maureen Murillo Avelino Gonzlez - 2 - EEL 4851 Engineering Data Structures JAVA Laboratory Manual Introduction to Java


  1. University of Central Florida Engineering Data Structures EEL 4851 JAVA LABORATORY MANUAL (Revised edition, 2002) Maureen Murillo Avelino González

  2. - 2 - EEL 4851 – Engineering Data Structures JAVA Laboratory Manual Introduction to Java – the Language................................................................................. 4 Chapter 1: Introduction to Java Programming ................................................................. 6 1. Creating a Java source file........................................................................................ 6 2. Compiling the source file ......................................................................................... 6 3. Running the application............................................................................................ 7 4. Understanding your "HelloWorld" application ........................................................ 7 4.1. Comments in Java code..................................................................................... 7 4.2. Defining a class. ................................................................................................ 7 4.3. The main method............................................................................................... 8 4.4. Using classes and objects. ................................................................................. 9 5. Writing your own program....................................................................................... 9 Chapter 2: Classes and Objects in Java .......................................................................... 11 1. Class definitions in Java ........................................................................................ 11 2. Defining data members in a Java class................................................................... 11 3. Constants in Java .................................................................................................... 13 4. Defining methods in a Java Class........................................................................... 13 5. The new operator ................................................................................................... 14 6. Constructors............................................................................................................ 14 7. Method Overloading............................................................................................... 15 8. Call-by-value and Call-by-reference ...................................................................... 15 Chapter 3: Control Structures and Memory Management in Java ................................. 17 1. Operators ............................................................................................................... 17 2. if/else – Selection structure ................................................................................... 17 3. switch – Selection structure................................................................................... 18 4. for – Repetition structure....................................................................................... 19 5. while – Repetition structure................................................................................... 19 6. do/while – Repetition structure ............................................................................. 19 7. Pointers and finalization of objects ....................................................................... 20 Chapter 4: Inheritance in Java ........................................................................................ 21 1. Extending a class ................................................................................................... 21 2. Inheritance of constructors .................................................................................... 22 3. Final classes and methods...................................................................................... 23 4. Abstract classes and methods ................................................................................ 23 5. Interfaces ............................................................................................................... 24 Chapter 5: Exception handling in Java........................................................................... 27 1. Exceptions in Computing ....................................................................................... 27 2. Exception in Java – the try block and the throw statement............................... 28 3. The catch block................................................................................................... 29 4. Predefined Exception classes.................................................................................. 30 5. Defining and using your own exception class........................................................ 31

  3. - 3 - 6. Multiple throws and catches ........................................................................ 32 7. The finally block ........................................................................................... 32 8. Passing the buck ..................................................................................................... 33 Chapter 6: Streams and File I/O in Java......................................................................... 34 1. Writing to binary files ............................................................................................ 34 2. Reading from binary files....................................................................................... 35 3. Exception Handling with File I/O .......................................................................... 36 4. Checking properties of the files – The File class.............................................. 37 5. Writing to text files................................................................................................. 37 6. Reading from text files ........................................................................................... 38 Chapter 7: Non-Primitive Data Types in Java................................................................ 40 1. Arrays ..................................................................................................................... 40 2. Multidimensional Arrays........................................................................................ 42 3. Ragged Arrays........................................................................................................ 43 4. Vectors.................................................................................................................... 44 Chapter 8: Windows Programming in Java.................................................................... 47 1. Graphical User Interfaces (GUI) in Java................................................................ 47 2. Event-Driven GUIs in Java .................................................................................... 48 3. Adding components................................................................................................ 50 4. Layout manager...................................................................................................... 53 Chapter 9: Applets in Java.............................................................................................. 55 1. A simple applet: the HelloWorld applet................................................................. 55 2. Creating an HTML file........................................................................................... 56 3. An applet with GUI components............................................................................ 58 4. Understanding another applet................................................................................. 59 Chapter 10: Mutimedia in Java: Images, Animation and Audio.................................... 62 1. Images..................................................................................................................... 62 2. Animations ............................................................................................................. 63 3. Sounds .................................................................................................................... 65 Chapter 11: Visual J++ (based on version 6.0) .............................................................. 66 1. Creating a console application................................................................................ 66 2. Using the WFC I/O package................................................................................... 67 3. Creating a windows application ............................................................................. 67 4. Creating an applet................................................................................................... 70 Chapter 12: Simple Data Types in Java ......................................................................... 73 1. The Stack................................................................................................................ 73 2. The Queue .............................................................................................................. 75 3. The List................................................................................................................... 75 4. The Binary Search Tree.......................................................................................... 77

Recommend


More recommend