TY - BOOK AU - Balagurusamy, E. TI - Programming with Java: a primer SN - 0074635425 (pb) U1 - 005.2752 PY - 0000///199 CY - New Delhi PB - Tata Mcgraw-hill KW - Computer Programming N1 - I FUNDAMENTALS OF OBJECT-ORIENTED PROGRAMMING I. I Introduction 1.2 Object-Oriented Paradigm 1.3 Basic Concepts of Object-Oriented Programming Objects and classes 3 Data abstraction and encapsulation 4 Inheritance 5 Polymorphism 6 Dynamic binding 6 Message communication 7 1.4 Benefits of OOP 1.5 Applications of OOP 1.6 Summary Review Questions Z JAVA EVOLUTION 2.1 Java History 2.2 Java Features Compiled and interpreted 13 Plcufcnrn4ndependent and portable 14 Object-oriented 14 Robust and secure 14 Distributed 14 Simple, small and familiar 15 Multithreaded and interactive 15 High performance 15 Dynamic and extensible 15 2.3 How Java Differs from C and C+ + Java and C 16 Java and G+ + 16 2.4 Java and Internet 2.5 Java and World Wide Web 2.6 Web Browsers HotJava 20 Netscape Navigator 21 Internet Explorer 21 2.7 Hardware and Software Requirements 2.8 Java Support Systems 2.9 Java Environment Java development kit 22 Application Programming Interface 23 2.10 Summary Review Questions OVERVIEW OF JAVA LANGUAGE 3.1 Introduction 3.2 Simple Java Program Class declaration 28 Opening brace 28 The main line 28 The output line 29 3.3 More of Java Use of math functions 30 Comments 30 3.4 An Application with Two Classes 3.5 Java Program Structure Documentation section 32 Package statement 32 Import statements 33 Interface statements 33 Class definitions 33 Main method class 33 3.6 Java Tokens Java character set 35 Keywords 35 Identifiers 36 Literals 37 Operators 37 Separators 37 3.7 Java Statements 3.8 Implementing a Java Program Creating the program 40 Compiling the program 40 Running the program 41 Machine neutral 42 3.9 Java Virtual Machine 3.10 Command Line Arguments 3.1 1 Programming Style 3.12 Summary Review Questions CONSTANTS, VARIABLES, AND DATA TYPES 4.1 Introduction 4.2 Constants Integer constants 47 Real constants 48 Single character constants 49 String constants 49 Backslash character constants 49 4.3 Variables 4.4 Data Types Integer types 51 Floating point types 52 Character type 53 Boolean type 53 4.5 Declaration of Variables 4.6 Giving Values to Variables Assignment statement 54 Read statement 55 4.7 Scope of Variables 4.8 Symbolic Constants Modifiability 58 Understandability 58 4.9 Type Casting Automatic conversion 59 4.10 Getting Values of Variables 4.1 1 Standard Default Values 4.12 Summary Review Questions OPERATORS AND EXPRESSIONS 5.1 Introduction 5.2 Arithmetic Operators Integer arithmetic 67 Real arithmetic 67 Mixed-mode arithmetic 68 5.3 Relational Operators 5.4 Logical Operators 5.5 Assignment Operators 5.6 Increment and Decrement Operators 5.7 Conditional Operator 5.8 Bitwise Operators 5.9 Special Operators instanceof operator 75 Dot operator 75 5.10 Arithmetic Expressions 5.1 1 Evaluation of Expressions 5.12 Precedence of Arithmetic Operators 5.13 Type Conversions in Expressions Automatic type conversion 78 Casting a value 79 5.14 Operator Precedence and Associativity 5.15 Mathematical Functions 5.16 Summary Review Questions 6 DECISION MAKING AND BRANCHING 6.1 Introduction 6.2 Decision Making with if Statement 6.3 Simple if Statement 6.4 The if...else Statement 6.5 Nesting of if...else Statements 6.6 The else If Ladder 6.7 The switch Statement 6.8 The ?: Operator 6.9 Summary Review Questions 7 DECISION MAKING AND LOOPING 7.1 Introduction 7.2 The while Statement 7.3 The do Statement 7.4 The for Statement AddUioncd features of for loop 119 Nesting of for haps 121 7.5 Jumps in Loops Jumping out of a hop 123 Skipping a part of a hop 123 7.6 Labelled Loops 7.7 Summary Review Questions 8 " CLASSES, OBJECTS AND METHODS 8.1 Introduction 8.2 Defining a Class 8.3 Adding Variables 8.4 Adding Methods 8.5 Creating Objects 8.6 Accessing Class Members 8.7 Constructors 8.8 Methods Overloading 8.9 Static Members 8.10 Nesting of Methods 8. i I Inheritance: Extending a Class Defining a subclass 142 Subclass constructor 145 Multilevel inheritance 145 Hierarchical inheritance 146 8.12 Overriding Methods 8.13 Final Variables and Methods 8.14 Final Classes 8.15 Finalizer Methods 8.16 Abstract Methods and Classes 8.17 Visibility Control public access 150 friendly access 150 protected access 151 private access 151 private protected access 151 Rules of Thumb 152 8.18 Summary Review Questions ARRAYS, STRINGS AND VECTORS 9.1 Arrays 9.2 One-Dimensional Arrays 9.3 Creating an Array Declaration of arrays 157 Creation of arrays 157 Initialization of arrays 158 Array length 160 9.4 Two-Dimensional Arrays Variable size arrays 164 9.5 Strings String arrays 166 String methods 166 StringBuffer class 167 9.6 Vectors 9.7 Wrapper Classes 9.8 Summary Review Questions 'l" INTERFACES: MULTIPLE INHERITANCE 10.1 Introduction 10.2 Defining Interfaces 10.3 Extending Interfaces 10.4 Implementing Interfaces 10.5 Accessing Interface Variables 10.6 Summary Review Questions *|T " PACKAGES: PUTTING CLASSES TOGETHER 1 1.1 Introduction 1 1.2 Java API Packages 1 1.3 Using System Packages 1 1.4 Naming Conventions 1 1.5 Creating Packages 1 1.6 Accessing a Package 1 1.7 Using a Package 1 1.8 Adding a Class to a Package 1 1.9 Hiding Classes 1 1.10 Summary Review Questions "i" " multithreaded programming 12.1 Introduction 12.2 Creating Threads 12.3 Extending the Thread Class Declaring the class 204 Implementing the run( ) method 205 Starting new thread 205 An example of using the thread class 205 12.4 Stopping and Blocking a Thread Stopping a thread 208 Blocking a thread 208 12.5 Life Cycle of a Thread Newborn state 209 Runnable state 210 Running state 210 Blocked state 212 Dead state 212 12.6 Using Thread Methods 12.7 Thread Exceptions 12.8 Thread Priority 12.9 Synchronization 12.10 implementing the 'Runnable' Interface 12.11 Summary Review Questions 13 MANAGING ERRORS AND EXCEPTIONS 7' 13.1 Introduction 13.2 Types of Errors Compile-time errors 223 Run-time errors 225 13.3 Exceptions 13.4 Syntax of Exception Handling Code 13.5 Multiple Catch Statements 13.6 Using finally Statement 13.7 Throwing Our Own Exceptions 13.8 Using Exceptions for Debugging 13.9 Summary Review Questions 14 APPLET PROGRAMMING V"" 14.1 Introduction Local and remote applets 237 14.2 How Applets Differ from Applications 14.3 Preparing to Write Applets 14.4 Building Applet Code 14.5 Applet Life Cycle Initialization state 244 Running state 244 Idle or stopped state 244 Dead state 245 Display state 245 14.6 Creating an Executable Applet 14.7 Designing a Web Page Comment section 246 Head section 246 Body section 247 14.8 Applet Tag 14.9 Adding Applet to HTML File 14.10 Running the Applet 14.1 1 More About Applet Tag 14.12 Passing Parameters to Applets 14.13 Aligning the Display 14.14 More About HTML Tags 14.15 Displaying Numerical Values 14.16 Getting Input from the User Program analysis 261 14.17 Summary Review Questions 15 GRAPHICS PROGRAMMING 15.1 Introduction 15.2 The Graphics Class 15.3 Lines and Rectangles 15.4 Circles and Ellipses 15.5 Drawing Arcs 15.6 Drawing Polygons 15.7 Line Graphs 15.8 Using Control Loops in Applets 15.9 Drawing Bar Charts 15.10 Summary Review Questions 16 MANAGING INPUT/OUTPUT FILES IN JAVA 16.1 Introduction 16.2 Concept of Streams 16.3 Stream Classes 16.4 Byte Stream Classes Input stream classes 285 Output stream classes 28 f 16.5 Character Stream Classes Reader stream Classes 289 Writer stream Classes 289 16.6 Using Streams 16.7 Other Useful I/O Classes 16.8 Using the File Class 16.9 Input / Output Exceptions 16.10 Creation of Files 16. I I Reading / Writing Characters 16.12 Reading / Writing Bytes 16.13 Handling Primitive Data Types 16.14 Concatenating and Buffering Files 16.15 Random Access Files 16.16 Interactive Input and Output Simple Input and Output 313 Graphical Input and Output 315 16.17 Other Stream Classes Object streams 323 Piped streams 323 Pushback streams 323 Filtered streams 324 ER -