TY - BOOK AU - Deitel,Paul J. TI - Java how to program SN - 9788120338326 (pb) U1 - 005.13 PY - 2010/// CY - New Delhi PB - PHI Learning KW - Java (Computer program language) KW - Object-oriented Programming (Computer science) N1 - I Introduction to Computers, the Internet and the Web 1 .1 Introduction 1.2 (Computers: 1 lardwarc and Software 1 3 C Computer ()r{;anization 1.4 F.arly Operating Systems 1.5 Personal, Distributed and (llietu/Server ( !omputing 1.6 The Internet and the World Wide Web 1 .7 Machine l,angua};es, Assembly l anguages and 1 iigh-1 evel l anguages 1.8 Histor)' of C. and C.+ + 1 .9 Mistory of Java 1.10 Java Cia.ss Libraries 1.1 1 Fortran, COBOL, Pascal and Ada 1.12 BASIC, Visual Basic, Visual C+ f, C# and .NE'l 1.13 Typical Java Development Environment 1.14 Notes about Java and Java How to Program, Eighth Edition 1.15 Test-Driving a Java Application 1.16 Software Engineering Case Study; Introduction to Object Technolog)- and the UML 1.17 Web 2.0 1.18 Software Technologies 1.19 Wrap-Up 1.20 Web Resources 2 introduction to Java Applications 2.1 Introduction 2.2 Our First Program in Java: Printing a Line of Text 2.3 Modifying Our First Java Program 2.4 Displaying Text with pri ntf 2.5 Another Application: Adding Integers 2.6 Memor\' Concepts 2.7 Arithmetic 2.8 Decision .Making; lupiality and Relational Operators 2.9 NX'rap-L'p 3 Introduction to Classes and Objects 3.1 IntrodiKtion 3.2 Cliasses. (Objects. .Methods aiul Instarue \ ;iriables .3..3 Declaring a ( lass with a .Method .ind Instantiating an (Mt|ect ol a ( lass 3.4 Declaring a .Method with a Parainctei 3.5 Instance \'ariables, set .Method.s atid ^el Methods 3.6 Primitive Types vs. Referetue 1 s pes 3.7 Initializing Objects with Constructors 3.8 Floating-Point Numbers and Type double 3.9 (Optional) (iUI and (Graphics C.tse .Study: Csing Dialog boxes 3.10 ^'rap-l'p 4 Control Statements: Part 1 4.1 Introduction 4.2 Algorithtns 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if...else Double-Selection Statement 4.7 whi le Repetition Statement 4.8 Formulating Algorithms: Counter-Controlled Repetition 4.9 Formulating Algorithms: Sentinel-Controlled Repetition 4.10 Formulating Algorithms: Nested Control Statements 4.11 Compound Assignment Operators 4.12 Increment and Decrement Operators 4.13 Primitive Types 4.14 (Optional) GUI and Graphics Case Study: Creating Simple Drawings 4.15 Wrap-Up 5 Control Statements: Part 2 5-1 li^troduction Counter-Controlled Repetition for Repetition Statement d"" Ml "r Statement V : Statement 5,9 Structute. .in>l ( K.iR 5.1 1 \Xrap-lp 6 Methods: A Deeper Look 6.1 IntrochKUon 6.2 Propr.uii .\Ioiliilf'> ni I.iv.i 6.3 static .Mctlimis. stat ic l ii-liis .iiui < l.issM.itli 6.4 I )c«.l.irin<: .\kiln)(.is with .Multiple I'.u.iiiu tets 6.5 Notes oil 1 )ecl.iriiig .iiul I siiit; Melhotls 6.6 .\1cthod-( .ill Stack ami .ActivaiifHi Records 6.7 Areument Promotion .iml ( .istiiit; 6.H lava .API Packages 6.9 (i.ise Studv; Random-Number (lener.ition 6.9.1 (ienerali/ed .Scaling, .md Shiltingol Random Numbers 6.9.2 Random-Number Repeatability lor Testitig and IVbuggitig 6.10 (".ase Studv: .A (lame of (ihanee; Intioducing l iiumei.itions 6.1 1 Scope ot Declarations 6.12 Method Overloading 6.13 (Optionalj (iUl and ( Iraphics ( ia.se Study: ( iolors and billed Shapes 6.14 Wrap-Up 7 Arrays and ArrayLi sts 7.1 Introduction 7.2 Arrays 7.3 Declaring and Oeating Arrays 7.4 Examples Using Arrays 7.5 Case Study: Card Shuffling and Dealing Simulation 7.6 Enhanced for Statement 7.7 Passing Arrays to Methods 7.8 Ca.se Study: Class GradeBook Using an Array to Store Crades 7.9 Multidimensional Arrays 7.10 Case Study: Class GradeBook Using a Two-Dimensional Array 7.1 1 Variable-Length Argument Lists 7.12 Using Command-Line Arguments 7.13 Class Arrays 7.14 Introduction to Collections and Class Ar rayLi st 7.15 (Optional) GUI and Graphics Case Study: Drawing Arcs 7.16 Wrap-Up 8 Classes and Objects: A Deeper Look 8.1 Introduction 8.2 Ti me Class Case Study 8.3 Controlling Access to Members 8.4 Referring to the Current Object's Members with the thi s Refere*"-^ S.s Time I lass C^isc Study: Ovcrloadcil ( ()nstructt)rN 8.6 IX'fauit and \o Aii;umcnt (:()iisiructors H." Notes on Sft and (if! Mcthoils 8.8 C .ontposition 8.') Jdunnerations 8.10 C.arliauc Collection and Method f inal ize 8.1 1 static (dass Menihers 8.12 static import 8.1.1 final Instance \ ariahle.s 8.1^ Time Cdass Cdise Study: Creatini; Packages 8.1 S Package Access 8.16 (Optional) CiUl and C iraphics Case Study: I'sing Objects with C.raphics 8.1" Wrap-Up 9 Object-Oriented Programming: Inheritance 9.1 Introduction 9.2 Superclasses and Subcla,s,se.s 9.3 protected Members 9.4 Relationship between Supercla.sses and Subclasses 9.4.1 Creating and Using a Commi ssionEmployee Class 9.4.2 Creating atid Using a BasePlusCommissionEmployee Cla.ss 9.4.3 Creating a Commi ssionEmployee-BasePlusConimi ssionEmployee Inheritance Hierarchy 9.4.4 Commi ssionEmployee-BasePlusCommi ssionEmployee Inheritance Hierarchy Using protected Instance Variables 9.4.5 CommissionEmployee-BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables 9.5 Constructors in Subclasses 9.6 Software Engineering with Inheritance 9.7 Object Class 9.8 (Optional) GUI and Graphics Ca.se Study: Displaying Text and Images Using Labels 9.9 Wrap-Up 10 Object-Oriented Programming: Polymorphism 10.1 Introduction 10.2 Polymorphism Examples 10.3 I )emonstrating Polymorphic Behavior 10.4 Abstract Classes and Methods 10.5 Ca« Study; Payroll System Using Polytnorphism 10.5.1 Abstract Superclass Employee 10.5.2 Concrete Subclass SalariedEmployee '0^5.3 Concrete Subclass HourlyEmployee 1 o's'^ Concrete Subclass Commi ssionEmployee • - •"direct Concrete Subdass BasePlusCommissionEmployee 10.5.6 Polymorphic Processing, Operator i nstanceof and Downcasting 10.5.7 Summary of the Allowed Assignments Between Superclass and Subclass Variables 10.6 fi nal Methods and Classes 10.7 Case Study: Creating and Using Interfaces 10.7.1 Developing a Payabl e Hierarchy 10.7.2 Interface Payable 10.7.3 Class Invoice 10.7.4 Modifying Class Empl oyee to Implement Interface Payabl e 10.7.5 Modifying Class SalariedEtnployee for Use in the Payable Hierarchy 10.7.6 Using Interface Payabl e to Process Invoi ces and Empl oyees Polymorphically 10.7.7 Common InteriFaces of the Java API 10.8 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism 10.9 Wrap-Up I I Exception Handling 11.1 Introduction 11.2 Error-Handling Overview 11.3 Example: Divide by Zero without Exception Handling 11.4 Example: Handling Ari thmeti cExcepti ons and InputMi smatchExcepti ons 11.5 When to Use Exception Handling 11.6 Java Exception Hierarchy 11.7 finally Block 11.8 Stack Unwinding 11.9 pri ntStackTrace, getStackTrace and getMessage 11.10 Chained Exceptions 11.11 Declaring New Exception Types 11.12 Preconditions and Postconditions 11.13 Assertions 11.14 Wrap-Up 12 ATM Case Study, Part I: Object-Oriented Design with the UML 12.1 Case Study Introduction 12.2 Examining the Requirements Document 12.3 Identifying the Classes in a Requirements Document 12.4 Identifying Class Attributes 12.5 Identifying Objects' States and Activities 12.6 Identifying Class Operations 12.7 Indicating Collaboration Among Objects 12.8 Wrap-Up I 3 ATM Case Study Part 2: Implementing an Object-Oriented Design 1 I lntroducti«)!i 13.2 St.irrinp lo Program the ( lasses ot the .\ I .\1 System 13.3 IiKorporatmg Inhentaiue aiul Polymorphism mto the .\ 1 .\t System 13.3.1 Implementing the A IM System Design (Ineorpoiatmg Inheritaiue) 13. t .3 r.\l ( ase Stiiiiv Implementation 13. 1.1 CdassATM 13.•1.2 (.lass Screen 13.-1.3 (lass Keypad 13.4.d (llass CashDi spenser 13.4.3 ( dass Deposi tSlot 13.4.() (ilass Account 13.4."" (dass BankDatabase 13.'i.H ( dass Transaction 1 3.4.9 ("lass Balancelnqui ry 13.4.10 C!lass Wi thdrawal 13.4.1 1 ("lass Deposi t 13.4.12 ("lass ATMCaseStudy 13.5 Wrap-1 p 14 GUI Components: Part I 14.1 Introduction 14.2 Java's New Nimbus Look-and-i-"ecl 14.3 Simple CiUI-Bascd Input/Output with DOptionPane 14.4 Overview of Swing (.omponents 14.5 Displaying I'cxr and Images in a Window 14.6 Text Fields and an Introduction to Event Handling with Nested Cla.sses 1^-7 Common GUI Event l ypes and Listener Interlaces 14.8 How Event Handling Works 14.9 3Button 14.10 Buttons That Maintain State ^4.10.1 DCheckBox 3RadioButton 14 12 and Using an Anonymous Inner Class for Event Handling II 1/ Lists 1 j Ever,, Handling 14.1 T Adapter Classes 14.16 3 Panel Subclass frtr 14\7 Key Event Hantiling "^"""8""' the Mouse Introduction Layout Managers j^lB.l FlowLayout 14 J'g2 BorderLayout "ri dLayout 14.19 Using Panels to Manage More Complex Layouts 14.20 JTextArea 14.21 Wrap-Up 15 Graphics and Java 20''''^ 15.1 Introduction 15.2 Graphics Contexts and Graphics Objects 15.3 Color Control 15.4 Manipulating Fonts 15.5 Drawing Lines, Rectangles and Ovals 15.6 Drawing Arcs 15.7 Drawing Polygons and Polylines 15.8 Java 2D API 15.9 Wrap-Up 16 Strings, Characters and Regular Expressions 16.1 Introduction 16.2 Fundamentals of Characters and Strings 16.3 Class String 16.3.1 String Constructors 16.3.2 String Methods length, charAt and getChars 16.3.3 Comparing Strings 16.3.4 Locating Characters and Substrings in Strings 16.3.5 Extracting Substrings from Strings 16.3.6 Concatenating Strings 16.3.7 Miscellaneous String Methods 16.3.8 String Method valueOf 16.4 Class StringBuilder 16.4.1 StringBuilder Constructors 16.4.2 StringBuilder Methods length, capacity, setLength and ensureCapacity 16.4.3 StringBuilder Methods charAt, setCharAt, getChars and reverse 16.4.4 StringBuilder append Methods 16.4.5 StringBuilder Insertion and Deletion Methods 16.5 Class Character 16.6 Tokenizing Strings 16.7 Regular Expressions, Class Pattern and Class Matcher 16.8 Wrap-Up I 7 Flits, Streams and Object Serialization 17.1 Introduction 17.2 Data Hierarchy 17.3 I-ilc> and Strcani\ 17.4 (-lass File 17.5 Sccjuciuial-Access I cxt l iles l^.^.l ( reaiiiv^ a Scijucntial-Access I e\l i ile 1~.3.2 Reading Data from a Secitiential-.Access I e\t l ile P.^.3 Case ut P.".2 Interfaces and ('lasses for Character-Based Input and Output 17.8 Opening Files with JFileCfiooser 17.9 Wrap-l'p 18 Recursion 18.1 Introduction 18.2 Recursion Concepts 18.3 F.xample Using Recursion: Factorials 18.4 FLxample Using Recursion: Fibonacci Series 18.5 Recursion and the Method-Call Stack 18.6 Recursion vs. Iteration 18.7 Towers of Hanoi 18.8 Fractals 18.9 Recursive Backtracking 18.10 Wrap-Up I 9 Searching, Sorting and Big O 19.1 Introduction 19.2 Searching Algorithms 19.2.1 Linear Search 19.2.2 Binary Search 19.3 Sorting Algorithms 19.3.1 Selection Sort 19.3.2 Insertion Sort 19.3.3 Merge Sort 19 4 Wrap-Up 20 Generic Collections 20.1 Introduction 20.2 Collections Overview 20.3 Type-Wrapper Classes for Primitive Types 20.4 Autoboxing and Auto-Unboxing 20.5 Interface Col 1 ecti on and Class Col 1 ecti ons 20.6 Lists 20.6.1 ArrayLi St and Iterator 20.6.2 LinkedList 20.7 Collections Methods 20.7.1 Method sort 20.7.2 Method shuffle 20.7.3 Methods reverse, fill, copy, max and min 20.7.4 Method hi narySearch 20.7.5 Methods addAl 1, frequency and disjoi nt 20.8 Stack Class of Package java.util 20.9 Class PriorityQueue and Interface Queue 20.10 Sets 20.11 Maps 20.12 Properties Class 20.13 Synchronized Collections 20.14 Unmodifiable Collections 20.15 Abstract Implementations 20.16 Wrap-Up 2 i Generic Classes and Methods 21.1 Introduction 21.2 Motivation for Generic Methods 21.3 Generic Methods: Implementation and Compile-Time Translation 21.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type 21.5 Overloading Generic Methods 21.6 Generic Classes 21.7 Raw Types 21.8 Wildcards in Methods That Accept Type Parameters 21.9 Generics and Inheritance: Notes 21.10 Wrap-Up 22 Custom Generic Data Structures 22.1 Introduction 22.2 Self-Referential Classes 22.3 Dynamic Memory Allocation 22.4 Linked Lists 22.5 Stacks 22.6 Queues 22.7 Trees 22.8 Wrap-Up 23 Applets and Java Web Start 2.11 IntroiiiKtmn 2.12 .S.ini(ilc Applets I'rosulcsi with the |[)K 2.1.^ Sitnple lava Ap['»let; I)rawitit; a .Sirinp 2.11! I.xeciitiiit:'^elcomeApplet in the applet viewer 2.1.12 I xeiiitmu an Applet in a \X eh ilowsei 2.14 Applet 1 ik'-( vtle Mctlnuls 2.15 Initiali/int: an Instance \ ariahle with Method init 2.16 .Saruih« ).\ Seciiritv .Model 2.1" Java \X eh Start and the lava Network I aiinih Protocol (|N1 P* 2.^.". 1 Paekaginu the DrawTest .Apfdet for I se with lava \X eh Start 2.1".2 j.N'l.P I)ociiment for the DrawTest Applet 2.18 VC'rap-L'[) 24 Multimedia: Applets and Applications 24.1 Introduction 24.2 Loading, Di.splaying and Scaling linages 24..3 Animating a Series of Images 24.4 Image Maps 24.5 Loading and Playing Audio Cdips 24.6 Playing Video and Other Media with Java Media I ramework 24.7 Wrap-Up 24.8 Web Resources 25 GUI Components: Part 2 25.1 Introduction 25.2 JSlider 25.3 Windows: Additional Notes 25.4 Using Menus with Frames 25.5 JPopupMenu 25.6 Pluggable Look-and-Feel 25.7 JDesktopPane and Hnternal Frame 25.8 DTabbedPane 25.9 Layout Managers: BoxLayout and CridBagLayout 25.10 Wrap-Up 26 Multithreading 26.1 Introduction 26.2 Thread States: Life Cycle of a I bread 26.3 Thread Priorities and Thread Scheduling 26.4 Creating and Executing Threads 26.4.1 Runnables and the Thread Class 26.4.2 Thread Management with the Executor Framework 26."^ rhrc.ul Synchroiii/ation 26.^.1 I'nsviu hroiii/fil n.ua Sharing 26.S.2 SyiKhroMi/cd 1 )ata Sharing Making (.Operations Atomu 26.6 Prothicer/C.onsumer Relationship without Synehroni/ation 26." Protivicer/C'.onsunier Relationship; ArrayBlockinqQueue 26.(S Proclucer/C"onsunier Relationship with .Synchronization 26.6 Prodiicer/C'onsiinier Relationship: Houiuled Biilkrs 26.10 Prochicer/Consumer Relationship: I he Lock ami Condition Interlaces 26.1 1 .Multithreading with (il l 26.1 1 .1 Performing (-omputations in a OX orker I hread 26.1 1 .2 Processing Intermediate Results with SvvingWorker 26.12 Interfaces Callable and Future 26.1.1 \X'rap-Up 27 Networking 27.1 Introduction 27.2 Manipulating URLs 27.3 Reading a File on a Web Server 27.4 Flstabli.shing a Simple SeiA'er Using Stream Sockets 27.3 Establi.shing a Simple Client Using Stream Sockets 27.6 C:iient/Server Interaction with Stream Socket C:onnections 27.7 (]onncctionle,ss Cdient/Servcr Interaction with Datagrams 27.8 Cdient/Sei^er ric- Tac-Toe Using a Multithreaded Server^ 27.9 [Web Bonus] Ca.se Study: Dei telMessenger Server and Cdient 27.10 Wrap-Up 28 Accessing Databases with JDBC 28.1 Introduction 28.2 Relational Databases 28.3 Relational Database Overview: The books Database 28.4 SQL 28.4.1 Basic SELECT Query 28.4.2 WHERE Clause 28.4.3 ORDER BY Clause 28.4.4 Merging Data from Multiple Tables; INNER DOIN 28.4.5 INSERT Statement 28.4.6 UPDATE Statement 28.4.7 DELETE Statement 28.5 Instructions for Installing MySQL and MySQL Connector/J 28.6 Instructions for Setting Up a MySQL User Account 28.7 Creating Database books in MySQL 28.8 Manipulating Databases with JDBC 28.8.1 Connecting to and Querying a Database 28.8.2 Querying the books Database 28.9 RowSet Interface 28.10 Java DB/Apache Derby ' 28.11 PreparedStatements 28.12 Stored Procedures 28.13 Transaction Processing 28.14 Wrap-Up 28.15 Web Resources 29 JavaScrvcr^'*' Faces Web Applications 29.1 Introduction 29.2 Simple HTTP Transactions 29.3 Multitier Application Architecture 29.4 Java Web Technologies 29.4.1 Servlets 29.4.2 JavaServer Pages 29.4.3 JavaServer Faces 29.4.4 Web Technologies in NetBeans 29.5 Creating and Running a Simple Application in NetBeans 29.5.1 Examining a JSP Document 29.5.2 Examining a Page Bean File 29.5.3 Event-Processing Life Cycle 29.5.4 Building a Web Application in NetBeans 29.6 JSF Components 29.6.1 Text and Graphics Components 29.6.2 Validation Using Validator Components and Custom Validators 29.7 Session Tracking 29.7.1 Cookies 29.7.2 Session Tracking with Session Beans 29.8 Wrap-Up 30 Ajax-Enabled JavaServcr^*^ Faces Web Applications 30.1 Introduction 30.2 Accessing Databases in Web Applications 30.2.1 Building a Web Application That Displays Data from a Daubase 30 2.2 Modifying the Page Bean File for the AddressBook Application 30.3 Ajax-Enabled JSF Components 30.4 Creating an Autocomplete Text Reld and Using Virtual Forms 30.4.1 Configuring Virtual Forms 30.4.2 JSP File with Virtual Forms and an Autocomplete Text Field 30.4.3 Providing Su^estions for an Autocomplete Text Field 30.4.4 Displaying the Contaa's Information 30.5 Wrap-Up 3 i Web Services 31.1 Introduction 31.2 Web Service Basics 31.3 Simple Object Access Protocol (SOAP) 31.4 Representational State Transfer (REST) 31.5 JavaScript Object Notation OSON) 31.6 Publishing and Consuming SOAP-Based Web Services 31.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans 31.6.2 Defining the Wei comeSOAP Web Service in NetBeans 31.6.3 Publishing the Wei comeSOAP Web Service from NetBeans 31.6.4 Testing the Wei comeSOAP Web Service with GlassFish Application Server's Tester Web Page 31.6.5 Describing a Web Service with the Web Service Description Langu^e (WSDL) 31.6.6 Creating a Client to Consume the Wei comeSOAP Web Service 31.6.7 Consuming the Wei comeSOAP Web Service 31.7 Publishing and Consuming REST-Based XML Web Services 31.7.1 Creating a REST-Based XML Web Service 31.7.2 Consuming a REST-Based XML Web Service 31.8 Publishing and Consuming REST-Based JSON Web Services 31.8.1 Creating a REST-Based JSON Web Service 31.8.2 Consuming a REST-Based JSON Web Service 31.9 Session Tracking in a SOAP-Based Web Service 31.9.1 Creating a B1 ackj ack Web Service 31.9.2 Consuming the B1 ack j ack Web Service 31.10 Consuming a Database-Driven SOAP-Based Web Service 31.10.1 Creating the Reservation Database 31.10.2 Creating a Web Application to Interact with the Reservation Service 31.11 Equation Generator; Returning User-Defined Types 31.11.1 Creating the REST-Based XML EquationCenerator Web Service 31.11.2 Consuming the REST-Based XML EquationCenerator Web Service 31.11.3 Creating the REST-Based JSON EquationCenerator Web Service 31.11.4 Consuming the REST-Based JSON EquationCenerator 31.12 Wrap-Up Web Servicedff ER -