TY - BOOK AU - Balagurusamy, E. TI - Programming with Java: a primer SN - 9780070141698 (pb) U1 - 005.13 PY - 2010/// CY - New Delhi PB - Tata MCgraw Hill KW - Computer Programming N1 - includes appendix; 1. Fundamentals of Object-Oriented Programming 1.1 Introduction 1 1.2 Object-Oriented Paradigm 2 1.3 Basic Concepts of Object-Oriented Programming 2 1.4 Benefits of OOP 7 r.5 Applications of OOP 8 1.6 Summary 8 Key Terms 8 Review Questions 8 2. Java Evolution 2.1 Java history 10 2.2 Java Features 11 2.3 How Java Differs from C and C-h- 14 2.4 Java and Internet 15 2.5 Java and World Wide Web 16 2.6 Web Browsers 17 2.7 Hardware and Software Requirements 18 2.8 Java Support Systems 19 2.9 Java Environment 19 2.10 Summary 21 Key Terms 22 Review Questions 22 3. Overview of Java Language 3.1 Introduction 23 3.2 Simple Java Program 24 3.3 More of Java 26 3.4 An Application with Two Classes 27 3.5 Java Program Structtire. 28 3.6 Java Tokens 29 3.7 Java Statements 32 3.8 Installing and Configuring Java 33 3.9 Implementing a Java Program 37 3.10 Java Virtual Machine 40 3.11 Command Line Arguments 41 3.12 Programming Style 43 3.13 Siunmary 43 Key Terms 43 Review Questions 44 I. Constants, Variables, and Data Types 4.1 Introduction 45 4.2 Constants 45 4.3 Variables 47 4.4 Data Types 48 4.5 Declaration of Variables 50 4.6 Giving Values to Variables 50 4.7 Scope of Variables 52 4.8 Symbolic Constants 53 4.9 Type Casting 54 4.10 Getting Values of Variables 56 4.11 Standard Default Values 57 4.12 Summary 58 Key Terms 58 Review Questions 58 Debugging Exercises 59 5. Operators and Expressions 5.1 Introduction 60 5.2 Arithmetic Operators 60 5.3 Relational Operators 62 5.4 Logical Operators 63 5.5 Assignment Operators 64 5.6 Increment and Decrement Operators 65 5.7 Conditional Operator 66 5.8 Bitwise Operators 66 5.9 Special Operators 67 5.10 Arithmetic Expressions 67 5.11 Evaluation of Expressions 67 5.12 Precedence of Arithmetic Operators 68 5.13 Type Conversions in Expressions 69 5.14 Operator Precedence and Associativity 72 5.15 Mathematical Functions 74 5.16 Summary 76 Key Terms 77 Review Questions 77 Debugging Exercises 78 6. Decision Making and Branching 6.1 Introduction 80 6.2 Decision Making with if Statement 80 6.3 Simple if Statement 81 6.4 The if...Else Statement 83 6.5 Nesting of if....Else Statements 85 6.6 The Else if Ladder 88 6.7 The Switch Statement 91 6.8 The ? : Operator 95 6.9 Summary 96 Key Terms 96 Review Questions 96 Debugging Exercises 99 7. Decision Making and Looping 7.1 Introduction 103 7.2 The While Statement 104 7.3 The Do Statement 105 7.4 The For Statement 107 7.5 Jumps in Loops 115 7.6 Labelled Loops 117 7.7 Summary 119 Key Terms 119 Review Questions 119 Debugging Exercises 121 8. Classes, Objects and Methods 8.1- Introduction 123 8.2 Defining a Class 123 8.3 Fields Declaration 124 8.4 Methods Declaration 124 8.5 Creating Objects 126 8.6 Accessing Class Members 127 8.7 Constructors 129 8.8 Methods Overloading 131 8.9 Static Members 132 8.10 Nesting of Methods 133 8.11 Inheritance: Extending a Class 134 8.12 Overriding Methods 138 8.13 Final Variables and Methods 139 8.14 Final Classes 139 8.15 Finalizer Methods 139 8.16 Abstract Methods Euid Classes 139 8.17 Methods with Varargs 140 8.18 Visibility Control 142 8.19 Summary 144 Key Terms 144 Review Questions 144 Debugging Exercises 146 9. Arrays, Strings and Vectors 9.1 Introduction 148 9.2 One-dimensional Arrays 148 9.3 Creating an Array 149 9.4 Two-dimensional Arrays 153 9.5 Strings 156 9.6 Vectors 159 9.7 Wrapper classes 161 9.8 Enumerated Types 165 9.9 Annotations 166 9.10 Summary 169 Key Terms 169 Review Questions 169 Debugging Exercises 171 10. Interfaces: Multiple Inheritance 10.1 Introduction 174 10.2 Defining Interfaces 174 10.3 Extending Interfaces 176 10.4 Implementing Interfaces 177 10.5 Accessing Interface Variables 179 10.6 Summary 180 Key Terms 181 Review Questions 181 Debugging Exercises 181 II. Packages: Putting Classes Together 11.1 Introduction 184 11.2 Java API Packages 185 11.3 Using System Packages 185 11.4 Naming Conventions 187 11.5 Creating Packages 187 11.6 Accessing a Package 188 11.7 Using a Package 189 11.8 Adding a Class to a Package 192 11.9 Hiding Classes 193 11.10 Static Import 193 11.11 Summary 195 Key Terms 195 Review Questions 195 Debugging Exercises 196 11. Multithreaded Programming 12.1 Introduction 198 12.2 Creating Threads 200 12.3 Extending the Thread Class 200 12.4 Stopping and'Blocking a Thread 204 12.5 Life Cycle of a Thread 204 12;6 Using Thread Methods 206 12.7 Thread Exceptions 208 12.8 Thread Priority 209 12.9 Synchronization 211 12.10 Implementing the'Runnable' Interface 212 12.11 Inter-thread Communication 214 12.12 Summary 216 Key Terms 216 Review Questions 216 Debugging Exercises 217 •13. Managing Errors and Exceptions 13.1 Introduction 220 13.2 Types of Errors 220 13.3 Exceptions 222 13.4 Syntax of Exception Handling Code 223 13.5 Multiple Catch Statements 226 13.6 Using Finally Statement 228 13.7 Throwing Our Own Exceptions 229 13.8 Using Exceptions for Debugging 230 13.9 Summary 231 Key Terms 231 Review Questions 231 Debugging Exercises 231 14. Applet Programming 14.1 Introduction 234 14.2 How Applets Differ from Applications 235 14.3 Preparing to Write Applets 235 14.4 Building Applet Code 236 14.5 Applet Life Cycle 238 14.6 Creating an Executable Applet 240 14.7 Designing a Web Page' 240 14.8 Applet Tag 242 14.9 Adding Applet to HTML File 242 14.10 Running the Applet 243 14.11 More About Applet Tag 243 14.12 Passing Parameters to Applets ,245 14.13 Aligning the Display 248 14.14 More About HTML Tags 249 14.15 Displaying Numerical Values 249 14.16 Getting Input from the User 250 14.17 Event Handling 253 14. r8 Summary 256 Key Terms 256 Review Questions 256 Debugging Exercises 256 15. Graphics'Programming 15.1 Introduction 260 15.2 The Graphics Class 260 15.3 Lines and Rectangles 263 15.4 Circles and Ellipses 265 15.5 Drawing Arcs 266 15.6 Drawing Polygons 267 15.7 Line Graphs 270 15.8 Using Control Loops in Applets 271 15.9 Drawing Bar Charts 272 15.10 Introduction to AWT Package 274 15.11 Introduction to Swings 274 15.12 Summary 276 Key Terms 276 17.1 Introduction 316 Review Questions 276 17.2 Overview of Interfaces 316 Debugging Exercises 276 17.3 Overview of Classes 321 17.4 Overview of Algorithms 329 16. Managing Input/Output Files in Java 278 Debugging Exercises 331 16.1 Introduction 278 16.2 Concept of Streams 279 16.3 Stream Classes 281 16.4 Byte Stream Classes 281 16.5 Character Stream Classes 284 16.6 Using Streams 285 16.7 Other Useful I/O Classes 286 16.8 Using the File Class 287 16.9 Input/Output Exceptions 287 16.10 Creation of Files 288 16.11 Reading/Writing Characters 289 16.12 Reading/Writing Bytes 291 16.13 Handling Primitive Data Types 294 16.14 Concatenating and Buffering Files 298 16.15 Random Access Files 300 16.16 Interactive Input and Output 302 16.17 Other Stream Classes 309 16.18 Summary 311 Key Terms 311 Review Questions 311 Debugging Exercises 312 17. Java Collections ER -