Lecture notes on Java pdf

which java gui framework,lecture notes on inheritance in java, lecture notes on exception handling in java,lecture notes on java programming language
Dr.DavisHardy Profile Pic
Published Date:22-07-2017
Your Website URL(Optional)
Java By Example Clayton Walnum C O N T E N T S Introduction ● Who This Book Is For ● Hardware and Software Requirements ● Compiling the Programs in This Book ● A Word to the Wise ● On to the Wonderful World of Java Chapter 1 Java Overview ● The Java Story ● Introducing Java ● Java Programs ● The Java Developer's Kit ● Where Is Java? ● Example: Installing HotJava ● Example: Installing the JDK ● Summary ● Review Questions ● Review Exercises Chapter 2 Running Java Applets ● The Sample Java Applets ❍ The Appletviewer Tool ❍ Example: Running TicTacToe ❍ The Animator Applet ❍ The BarChart Applet ❍ Other Demo Applets ● Adding Applets to an HTML Document ❍ Optional Attributes for Applets ❍ Applet Parameters ❍ Non-Java Browsers ❍ Example: A Java-Powered Home Page ● Summary ● Review Questions ● Review Exercises Chapter 3 Applets and the Internet ● Local and Remote Applets ❍ Local Applets ❍ Remote Applets ● Clients and Servers ● Security ● Example: Your Pages on the Web ● Summary ● Review Questions ● Review Exercises Chapter 4 Object-Oriented Programming Concepts ● From Switches to Objects ● An Obvious, Yet Brilliant, Solution ● Object-Oriented Programming ❍ Encapsulation ❍ Classes as Data Types ❍ Inheritance ❍ Polymorphism ❍ Example: Encapsulation, Inheritance, and Polymorphism ● Summary ● Review Questions ● Review Exercises Chapter 5 Constants and Variables ● Constants ● Variables ● Naming Constants and Variables ● Example: Creating Your Own Identifiers ● Data Types ❍ Integer Values ❍ Floating-Point Values ❍ Character Values ❍ Boolean Values ● Variable Scope ❍ Example: Determining a Variable's Scope ● Summary ● Review Questions ● Review Exercises Chapter 6 Simple Input and Output ● Windows and Graphics ● Displaying Text in an Applet ❍ Example: Creating and Running Applet1 ❍ How Applet1 Works ● Getting Input from the User ❍ How Applet2 Works ❍ Example: Retrieving text from a TextField control ❍ How Applet3 Works ● Displaying Numerical Values ● Summary ● Review Questions ● Review Exercises Chapter 7 Math Operators ● The Addition Operator ❍ Example: Using the Addition Operator ❍ Example: Multiple Additions ● The Subtraction Operator ❍ Example: Using the Subtraction Operator ❍ Example: Multiple Subtractions Using Mixed Data Types ❍ Example: Casting a Result to a Different Data Type ● The Multiplication Operator ❍ Example: Multiplication and Data Types ● The Division Operator ❍ Example: Integer Versus Floating-Point Division ● The Modulo Operator ● The Increment Operator ● The Decrement Operator ● Example: Using Mathematical Calculations in an Applet ❍ How Applet5 Works ● The Order of Operations ❍ Example: Order of Operations ❍ Example: More Order of Operations ❍ Example: Still More Order of Operations ❍ Example: One Last Order of Operations ● Summary ● Review Questions ● Review Exercises Chapter 8 Expressions ● Types of Expressions ● Expressions Within Expressions ● Comparison Operators ❍ Example: Using Comparison Operators ● Logical Operators ❍ Example: Using Logical Operators ❍ Example: Using Multiple Logical Operators ❍ Example: Combining Different Comparison and Logical Operators ● Writing Logical Expressions ● Order of Operations ● Summary ● Review Questions ● Review Exercises Chapter 9 The if and switch Statements ● Controlling Program Flow ● Program Flow and Branching ● The if statement ❍ Example: The Form of an if Statement ❍ Multiple if Statements ❍ Multiple-Line if Statements ❍ The else Clause ❍ Example: Using the if Statement in a Program ● The switch Statement ❍ Example: Using the break Statement Correctly ❍ Example: Using the switch Statement in a Program ● Summary ● Review Questions ● Review Exercises Chapter 10 The while and do-while Loops ● The while Loop ❍ Example: Using a while Loop ❍ Example: Using a while Loop in a Program ● The do-while Loop ❍ Example: Using a do-while Loop ❍ Example: Using a do-while Loop in a Program ● Summary ● Review Questions ● Review Exercises Chapter 11 The for Loop ● Introducing the for Loop ● Example: Using a for Loop ● Example: Using a for Loop in a Program ● Changing the Increment Value ● Example: Looping with Different Increments ● Using Variables in Loops ● Example: Controlling for Loops with Variables ● Summary ● Review Questions ● Review Exercises Chapter 12 Functions ● The Top-Down Approach to Programming ● Example: Using Functions as Subroutines ● Defining and Calling Functions ● Example: Using Functions to Return Values ● Example: Putting Functions to Work ● Summary ● Review Questions ● Review Exercises Chapter 13 Arrays ● An Introduction to Arrays ❍ Example: Creating an Array ❍ Example: Using a Variable as a Subscript ● Multidimensional Arrays ❍ Example: Creating a Two-Dimensional Array ● Example: Using Two-Dimensional Arrays in an Applet ● Summary ● Review Questions ● Review Exercises Chapter 14 Classes ● Classes and Objects ❍ Defining a Simple Class ❍ Declaring Fields for a Class ❍ Defining a Constructor ❍ Example: Creating an Object by Calling a Constructor ❍ Defining Methods ● Example: Using Classes in Applets ● Understanding the Applet ● Using Inheritance ❍ Creating a Subclass ❍ Adding Fields and Methods to the Subclass ❍ Example: Adding Fields and Methods ● Example: Using a Subclass in a Program ● Overriding Methods of the Superclass ● The this Keyword ● Summary ● Review Questions ● Review Exercises Chapter 15 Writing a Simple Applet ● The Simplest Java Applet ● The Five Stages of an Applet's Life Cycle ● Example: Overriding the Life Cycle Methods ● Summary ● Review Questions ● Review Exercises Chapter 16 Drawing Graphics ● The Applet's Canvas ● Example: Using the Coordinate System ● Drawing Shapes ● Example: Drawing a Rectangle ● Example: Drawing Other Shapes ● Understanding the ShapeApplet Applet ❍ Drawing Ovals ❍ Drawing Arcs ❍ Example: Drawing Arcs in an Applet ❍ Drawing Polygons ● Summary ● Review Questions ● Review Exercises Chapter 17 Graphical Text ● Dealing with Graphical Text ❍ Getting Font Attributes ❍ Example: Displaying Font Information ❍ Getting Font Metrics ❍ Example: Displaying Font Metrics ● Creating Fonts ❍ Example: Creating a Font with Multiple Styles ❍ Using the Font ❍ Example: Displaying Different Sized Fonts ● Summary ● Review Questions ● Review Exercises Chapter 18 Label and Button Controls ● Labels ❍ Example: Creating a Label ❍ Methods of the Label Class ● Buttons ❍ Example: Adding a Button to an Applet ❍ Handling Multiple-Button Events ❍ Example: Handling Multiple Buttons in an Applet ● Summary ● Review Questions ● Review Exercises Chapter 19 Checkbox and TextField Controls ● Checkboxes ❍ Example: Creating Nonexclusive Checkboxes ❍ Checkbox Groups ❍ Checkbox Methods ❍ Example: Handling Checkboxes in an Applet ❍ Responding to a Checkbox Event ❍ Example: Handling Checkbox Events in an Applet ● TextFields ❍ TextField Methods ❍ Example: Using Echo Characters ● Summary ● Review Questions ● Review Exercises Chapter 20 Choice Menu, Text Area, and Scrolling List Controls ● Choice Menus ❍ Example: Creating a Choice Menu ❍ Choice Menu Methods ❍ Example: Responding to Menu Events in an Applet ● Scrolling Lists ❍ Example: Creating a Single-Selection List ❍ Example: Creating a Multiple-Selection List ❍ Example: Creating a Scrolling List ❍ Methods of the List Class ❍ Example: Using a Scrolling List in an Applet ● The TextArea Control ❍ Example: Creating a TextArea Control ❍ Methods of the TextArea Class ● Summary ● Review Questions ● Review Exercises Chapter 21 Scrollbar and Canvas Controls ● Scrollbars ❍ Example: Creating a Scrollbar ❍ Responding to a Scrollbar ❍ Example: Using a Scrollbar in an Applet ❍ Canvases ❍ Example: Using a Canvas in an Applet ● Summary ● Review Questions ● Review Exercises Chapter 22 Panels and Layout Managers ● Panels ❍ Example: Creating and Using Panels ● Layout Managers ● The FlowLayout Manager ❍ Example: Creating a FlowLayout Manager ● The GridLayout Manager ❍ Creating a GridLayout Manager ● The BorderLayout Manager ❍ Creating a BorderLayout Manager ● The CardLayout Manager ❍ The CardLayout Manager Methods ❍ Example: Creating a CardLayout Manager ● The GridBagLayout Manager ❍ Creating and Setting the GridBagLayout Manager ❍ Creating and Setting a GridBagConstraints Object ❍ Example: Using a GridBagLayout Manager in an Applet ❍ Understanding the GridBagApplet Applet ● Summary ● Review Questions ● Review Exercises Chapter 23 Windows and Menu Bars ● Displaying a Window ❍ Example: Displaying a Window in an Applet ❍ Example: Creating a Window Class ❍ Example: Adding Components to a Window ● Using Menu Bars ❍ Creating and Setting a MenuBar Object ❍ Adding Menus to a Menu Bar ❍ Adding Menu Items to Menus ❍ Example: Using a Menu Bar in a Frame Window ● Summary ● Review Questions ● Review Exercises Chapter 24 Dialog Boxes ● Using a Dialog Box ❍ Creating the Dialog Box ❍ Creating the Dialog Box's Layout ❍ Displaying the Dialog Box ❍ Removing the Dialog Box ❍ Methods of the Dialog Class ❍ Example: A Dialog Box for Text Input ● Summary ● Review Questions ● Review Exercises Chapter 25 Mouse and Keyboard Events ● The Event Object ● The Mouse ❍ Handling Mouse Clicks ❍ Example: Using Mouse Clicks in an Applet ❍ Handling Mouse Movement ❍ Example: Responding to Mouse Movement in an Applet ● The Keyboard ❍ Responding to Key Presses ❍ Predefined Key Constants ❍ Key Modifiers ❍ Example: Using Key Presses in an Applet ● Handling Events Directly ❍ Example: Overriding handleEvent() in an Applet ● Summary ● Review Questions ● Review Exercises Chapter 26 Configurable Applets ● Types of Users ● Parameters and Applets ❍ Example: Setting and Retrieving a Parameter's Value ❍ Example: Using a Parameter in an Applet ● Multiple Parameters ❍ Example: Using Multiple Parameters in an Applet ● Default Parameter Values ❍ Example: Using Default Parameters in an Applet ● Summary ● Review Questions ● Review Exercises Chapter 27 Images and Sounds ● Image Types ● Loading and Displaying an Image ❍ Example: Using the getDocumentBase() Method ❍ Example: Using the getCodeBase() Method ❍ Loading an Image ❍ Displaying an Image ❍ Example: Displaying an Image in an Applet ● Playing a Sound ❍ Example: Using the play() Method ❍ Example: Playing a Sound in an Applet ❍ Controlling Sounds ❍ Example: Using an AudioClip in an Applet ● Summary ● Review Questions ● Review Exercises Chapter 28 Communications ● URL Objects ❍ Example: Creating an URL Object ❍ URL Exceptions ● The Applet Context ❍ Example: Using an AppletContext to Link to an URL ❍ Example: Using an AppletContext in an Applet ● Creating a "Favorite URLs" Applet ● Summary ● Review Questions ● Review Exercises Chapter 29 Packages and Interfaces ● Packages ❍ Creating Your Own Packages ❍ Example: Creating a Simple Package ❍ Example: Using the New Package ❍ Example: Extending the Package ● Interfaces ❍ The Basic Interface ❍ Example: Creating an Interface ❍ Implementing an Interface ● Summary ● Review Questions ● Review Exercises Chapter 30 Exceptions ● Java's Exceptions ● Throwing an Exception ● Types of Exceptions ● Determining the Exceptions to Handle ❍ Example: Catching a Runtime Exception ❍ Example: Handling Multiple Exceptions ● Summary ● Review Questions ● Review Exercises Chapter 31 Threads ● Two Kinds of Threads ● Converting a Class to a Thread ❍ Declaring the Class as Implementing the Runnable Interface ❍ Implementing the run() Method ❍ Declaring a Thread Object ❍ Creating and Starting the Thread Object ❍ Stopping the Thread ❍ Example: Using a Thread in an Applet ● Deriving a Class from Thread ❍ Example: Creating a Thread Class ❍ Example: Using a Separate Thread in an Applet ● Synchronizing Multiple Threads ❍ Example: Using a Synchronized Method ❍ Understanding ThreadApplet3 ● Summary ● Review Questions ● Review Exercises Chapter 32 Writing Java Applications ● About Java Applications ● The Simplest Java Application ❍ Example: Building an Application ❍ Example: Getting an Application's Arguments ● Windowed Applications ❍ Example: Changing an Applet to an Application ❍ Understanding the FaceApp Application ● Summary ● Review Questions ● Review Exercises Chapter 33 Development Tools Overview ● The Tools ● Using Appletviewer ❍ Example: Loading More Than One Applet at a Time ❍ Running the Debugger from Appletviewer ● Using HotJava ● Using Java's Documentation Creator ❍ Javadoc Tags ❍ Example: Using Doc Tags ❍ Example: Documenting an Applet ❍ Javadoc Options ● Using the Disassembler ● Using the C Header Generator ● Using the Debugger ● Summary ● Review Questions ● Review Exercises Chapter 34 Using the Compiler ● What the Compiler Does ● Running the Compiler ❍ Setting the Class Path ❍ Specifying the Target Directory ❍ Example: Setting the Target Directory ❍ Creating Debugging Tables ❍ Example: Adding Debugging Tables to an Applet ❍ Suppressing Warnings ❍ Optimizing a Program ❍ Switching On Verbose Output ● Summary ● Review Questions ● Review Exercises Chapter 35 Using the Interpreter ● What the Interpreter Does ● Running the Interpreter ❍ Keeping Files Up to Date ❍ Setting the Class Path ❍ Switching On Verbose Output ❍ Example: Running an Application with Verbose Output ❍ Getting Help ● Summary ● Review Questions ● Review Exercises Chapter 36 The Java Class Libraries ● The Packages ● The java.lang Package ❍ Data-Type Wrappers ❍ Example: Using the Data-Type Wrappers ❍ The System Class ❍ Example: Getting System Properties ❍ The Math Class ❍ The String Class ❍ Example: Using the String Class ● The io Package ❍ Example: Reading a File ● The awt Package ● Summary ● Review Questions ● Review Exercises Appendix A Answers to Review Questions ● Chapter 1 ● Chapter 2 ● Chapter 3 ● Chapter 4 ● Chapter 5 ● Chapter 6 ● Chapter 7 ● Chapter 8 ● Chapter 9 ● Chapter 10 ● Chapter 11 ● Chapter 12 ● Chapter 13 ● Chapter 14 ● Chapter 15 ● Chapter 16 ● Chapter 17 ● Chapter 18 ● Chapter 19 ● Chapter 20 ● Chapter 21 ● Chapter 22 ● Chapter 23 ● Chapter 24 ● Chapter 25 ● Chapter 26 ● Chapter 27 ● Chapter 28 ● Chapter 29 ● Chapter 30 ● Chapter 31 ● Chapter 32 ● Chapter 33 ● Chapter 34 ● Chapter 35 ● Chapter 36 Appendix B GlossaryAppendix C IDEs and Tools ● IDEs ❍ Diva ❍ Java+ ❍ JavaMaker ● Tools ❍ AppletGen ❍ VbToJava ❍ PortaFilter ● Summary Credits Java By Example Copyright© 1996 by Que® Corporation All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 W. 103rd Street, Indianapolis, IN 46290. You may reach Que's direct sales line by calling 1-800-428-5331. ISBN: 0-7897-0814-0 This book is sold as is, without warranty of any kind, either express or implied, respecting the contents of this book, including but not limited to implied warranties for the book's quality, performance, merchantability, or fitness for any particular purpose. Neither Que Corporation nor its dealers or distributors shall be liable to the purchaser or any other person or entity with respect to any liability, loss, or damage caused or alleged to have been caused directly or indirectly by this book. All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Que cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. HTML conversion by : M/s. LeafWriters (India) Pvt. Ltd. Website : http://leaf.stpn.soft.net e-mail : leafwritersleaf.stpn.soft.net President and Publisher : Roland Elgey Associate Publisher : Joseph B. Wikert Director of Marketing : Lynn E. Zingraf Editorial Services Elizabeth Managing Editor Sandy Doell Director Keaffaber Title Manager Bryan Gambrel Acquisitions Fred Stone Editor Product Director Ben Milstead Production Editor Mitzi Foster Gianakos Editors Anne Owen, Assistant Product Kim Margolius Joe Williams Marketing Manager Technical Editors David Medinets Acquisitions Jane Brownlow Coordinator Operations Patty Brooks Editorial Andrea Duvall Coordinator Assistant Book Designer Kim Scott Cover Designer Ruth Harvey Production Team Steve Adams, Marcia Brizendine, Jason Carr, Jenny Earhart, Joan Evan, Jessica Ford, Trey Frank, Amy Gornik, Jason Hand, Daniel Harris, Damon Jordan, Daryl Kessler, Clint Lahnen, Bob LaRoche, Kaylene Riemen, Laura Robbins, Bobbi Satterfield, Kelly Warner, Jeff Yesh, Jody York Indexer John Hulse About the AuthorClayton Walnum, who has a degree in computer science, has been writing about computers for almost 15 years and has published hundreds of articles in major computer publications. He is also the author of over 25 books, which cover such diverse topics as programming, computer gaming, and application programs. His most recent book is Windows 95 Game SDK Strategy Guide, also published by Que. His other titles include the award-winning Building Windows 95 Applications with Visual Basic (Que), 3-D Graphics Programming with OpenGL (Que), Borland C++ 4.x Tips, Tricks, and Traps (Que), Turbo C++ for Rookies (Que), Dungeons of Discovery (Que), PC Picasso: A Child's Computer Drawing Kit (Sams), Powermonger: The Official Strategy Guide (Prima), DataMania: A Child's Computer Organizer (Alpha Kids), Adventures in Artificial Life (Que), and C-manship Complete (Taylor Ridge Books). Mr. Walnum lives in Connecticut with his wife Lynn and their four children, Christopher, Justin, Stephen, and Caitlynn. Acknowledgments I would like to thank the following people for their contribution to this book: Joe Wikert for his confidence in my writing; Fred Slone for keeping everything running smoothly; Mitzi Gianakos, Anne Owen, and Joe Williams for keeping my abuse of the English language to a minimum; David Medinets for checking the facts; and all the other fine folks at Que. And, as always, thanks to my family-Lynn, Christopher, Justin, Stephen, and Caitlynn. We'd Like to Hear from You As part of our continuing effort to produce books of the highest possible quality, Que would like to hear your comments. To stay competitive, we really want you, as a computer book reader and user, to let us know what you like or dislike most about this book or other Que products. You can mail comments, ideas, or suggestions for improving future editions to the address below, or send us a fax at (317) 581-4663. Our staff and authors are available for questions and comments through our Internet site at http://www.mcp.com/que., and Macmillan Computer Publishing also has a forum on CompuServe (type GO QUEBOOKS at any prompt). In addition to exploring our forum, please feel free to contact me personally to discuss your opinions of this book: I'm bmilsteadque.mcp.com on the Internet, and 102121,1324 on CompuServe. Thanks in advance-your comments will help us to continue publishing the best books available on

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.