JAVA Programming

Book description

JAVA Programming introduces the subject in a simple and lucid style. This book explains programming concepts and software development practices for solving problems in a clear and precise manner. Every chapter of the book is supported with a wide variety of solved examples and end-of-chapter exercises to help students master this subject.

Table of contents

  1. Cover
  2. Title Page
  3. Brief Contents
  4. Contents
  5. Dedication
  6. Introduction
  7. Preface
  8. PART I — JAVA BASICS
    1. Chapter 1: Java Data Types, Operators and Console I/O Statements
      1. 1.1 Introduction
      2. 1.2 Java, World Wide Web and Sensor Devices
      3. 1.3 Java Editing Environments
      4. 1.4 Data Types and Variables
      5. 1.5 Constants in Java
      6. 1.6 Java Operators
      7. 1.7 Type Casting and Boxing
      8. 1.8 Console I/O Statements
        1. 1.8.1 Command line
        2. 1.8.2 Scanner
        3. 1.8.3 BufferedReader
        4. 1.8.4 DataInputStream
        5. 1.8.5 Console
      9. 1.9 Summary
      10. Key Terms
      11. Review Questions
      12. Exercises
    2. Chapter 2: Java Conditional and Looping Statements
      1. 2.1 Introduction
      2. 2.2 Conditional Statements
        1. 2.2.1 if statement
        2. 2.2.2 Problem: Finding biggest of three integers
        3. 2.2.3 if-else statement
        4. 2.2.4 if-else-if statement
        5. 2.2.5 Nested if statement
        6. 2.2.6 Problem: Checking leap year
        7. 2.2.7 Multipoint switch statement
        8. 2.2.8 String cases for switch
      3. 2.3 Java Looping Statements
        1. 2.3.1 while loop
        2. 2.3.2 do-while loop
        3. 2.3.3 for loop
        4. 2.3.4 Problem: Generating multiplication table
        5. 2.3.5 break, continue and assert statements
      4. 2.4 Summary
      5. Key Terms
      6. Review Questions
      7. Exercises
    3. Chapter 3: Arrays in Java
      1. 3.1 Introduction
      2. 3.2 Declaring and Initializing Arrays
      3. 3.3 Accessing Array Elements
      4. 3.4 Problem: Sequential Search for a Key
      5. 3.5 Problem: Binary Search for a Key
      6. 3.6 The for-each Statement
      7. 3.7 Problem: Finding Euclidean Distance Between Two Vectors
      8. 3.8 Problem: Reverse an Array Without Copying
      9. 3.9 Multidimensional Arrays
      10. 3.10 Problem: Transpose of a Matrix
      11. 3.11 Summary
      12. Key Terms
      13. Review Questions
      14. Exercises
    4. Chapter 4: Methods in Java
      1. 4.1 Introduction
      2. 4.2 Defining a Method
      3. 4.3 Calling a Method
      4. 4.4 Problem: Nested Method Calls
      5. 4.5 Problem: Calculate Area of Geometric Objects
      6. 4.6 Problem: Generate Prime Numbers
      7. 4.7 Recursion: Power and Pitfalls
      8. 4.8 Method Overloading
      9. 4.9 Passing One-Dimensional Arrays to Methods
      10. 4.10 Problem: Method to Sort Names
      11. 4.11 Passing Two-Dimensional Arrays to Methods
      12. 4.12 Variable Length Argument Lists
      13. 4.13 Summary
      14. Key Terms
      15. Review Questions
      16. Exercises
  9. PART II — OBJECT ORIENTED JAVA PROGRAMMING
    1. Chapter 5: Classes and Objects
      1. 5.1 Introduction
      2. 5.2 Object-Oriented Programming Paradigm
      3. 5.3 Creating a Class
      4. 5.4 Problem: Designing Object-Oriented College Application
      5. 5.5 Creating Data Members
      6. 5.6 Creating Member Functions
      7. 5.7 Static Data and Methods
      8. 5.8 Array of Objects
      9. 5.9 Objects as Arguments to Methods
      10. 5.10 Summary
      11. Key Terms
      12. Review Questions
      13. Exercises
    2. Chapter 6: Inheritance and Polymorphism
      1. 6.1 Introduction
      2. 6.2 Constructors
      3. 6.3 Default Constructor
      4. 6.4 Parameterized Constructor
      5. 6.5 Constructor Overloading
      6. 6.6 Essential Java.lang Classes
        1. 6.6.1 Math
        2. 6.6.2 Character
        3. 6.6.3 String
        4. 6.6.4 StringBuffer
        5. 6.6.5 StringBuilder
      7. 6.7 Inheritance
      8. 6.8 Calling Base Class Constructor
      9. 6.9 Calling Base Class Data Member with Super
      10. 6.10 Overriding and Polymorphism
      11. 6.11 Aggregation versus Inheritance
      12. 6.12 Object and Object Cloning
      13. 6.13 Checking Object’s Class Type
      14. 6.14 Preventing Inheritance and Overriding
      15. 6.15 Visibility of Members of a Class
      16. 6.16 Inner Classes
      17. 6.17 Summary
      18. Key Terms
      19. Review Questions
      20. Exercises
    3. Chapter 7: More on Objects and Exceptions
      1. 7.1 Introduction
      2. 7.2 Abstract Classes
        1. 7.2.1 Defining abstract classes
        2. 7.2.2 Defining abstract methods
      3. 7.3 Interfaces
        1. 7.3.1 Declaring interfaces
        2. 7.3.2 Implementing interfaces
        3. 7.3.3 Problem: Flyable interface
      4. 7.4 Java Enums
        1. 7.4.1 Basics of enum
        2. 7.4.2 Advanced features of enum
      5. 7.5 Packages
        1. 7.5.1 Creating a package
        2. 7.5.2 Importing packages
        3. 7.5.3 Including classes to package
        4. 7.5.4 Subpackages
        5. 7.5.5 Protected members revisited
      6. 7.6 Exception Handling
        1. 7.6.1 Try-catch-finally statements
        2. 7.6.2 Multicatch statement
        3. 7.6.3 Exception hierarchy
        4. 7.6.4 User-defined exceptions with throw and throws
        5. 7.6.5 Extending RuntimeException class
      7. 7.7 Summary
      8. Key Terms
      9. Review Questions
      10. Exercises
  10. PART III — JAVA CONTAINERS FOR HOLDING OBJECTS
    1. Chapter 8: Sequence Containers
      1. 8.1 Introduction
      2. 8.2 Collection Taxonomy
      3. 8.3 Vectors
        1. 8.3.1 Enumeration
        2. 8.3.2 Type-specific vectors
      4. 8.4 StringTokenizer
      5. 8.5 Stack
        1. 8.5.1 Character stack
        2. 8.5.2 Problem: Brackets matching
      6. 8.6 Iterators
      7. 8.7 PriorityQueue
      8. 8.8 ArrayList
        1. 8.8.1 Type-safe ArrayLists
        2. 8.8.2 Problem: Shopping cart
        3. 8.8.3 Problem: Search an element inside array
        4. 8.8.4 Problem: Merge two arrays
        5. 8.8.5 Problem: Remove all duplicates in an array
      9. 8.9 Linkedlist
        1. 8.9.1 Problem: Designing stack using LinkedList
        2. 8.9.2 Type-safe LLStack using generics
      10. 8.10 Summary
      11. Key Terms
      12. Review Questions
      13. Exercises
    2. Chapter 9: Map Containers
      1. 9.1 Introduction
      2. 9.2 Hashtable
      3. 9.3 Problem: Word Counting in a Text
      4. 9.4 Problem: Couples-Sensitive Brackets Checker
      5. 9.5 HashMap
      6. 9.6 Multimaps
      7. 9.7 Nested HashMaps
      8. 9.8 LinkedHashMap
      9. 9.9 TreeMap
      10. 9.10 Problem: Random Number Generator
      11. 9.11 Properties
      12. 9.12 Summary
      13. Key Terms
      14. Review Questions
      15. Exercises
    3. Chapter 10: Set Containers
      1. 10.1 Introduction
      2. 10.2 Set Interface
      3. 10.3 HashSet
      4. 10.4 Problem: Counting Duplicates in a Text
      5. 10.5 LinkedHashSet
      6. 10.6 TreeSet
      7. 10.7 Summary
      8. Key Terms
      9. Review Questions
      10. Exercises
    4. Chapter 11: Sorting and Searching
      1. 11.1 Introduction
      2. 11.2 Sorting and Searching Using Arrays Class
      3. 11.3 Filling and Copying Arrays
      4. 11.4 Comparing Arrays
      5. 11.5 Sorting Primitive Arrays
      6. 11.6 Sorting String Objects
      7. 11.7 Array Sorting Using Comparable
      8. 11.8 Array Sorting Using Comparator
      9. 11.9 Searching Sorted Arrays
      10. 11.10 Sorting and Searching Using Collections Class
      11. 11.11 Sorting Lists Using Comparable
      12. 11.12 Sorting Lists Using Comparator
      13. 11.13 Summary
      14. Key Terms
      15. Review Questions
      16. Exercises
  11. PART IV — JAVA THREADS AND IO STREAMS
    1. Chapter 12: Concurrency Using Threads
      1. 12.1 Introduction
      2. 12.2 Multithreading Using Thread Class
      3. 12.3 Making Threads to Sleep
      4. 12.4 Yielding Control to Other Threads
      5. 12.5 Problem: Multithreaded Adder
      6. 12.6 Suspending Caller Thread
      7. 12.7 Daemon Threads
      8. 12.8 Thread Priority
      9. 12.9 Multithreading Using Runnable
      10. 12.10 Thread Synchronization for Resource Sharing
      11. 12.11 Synchronized Methods
      12. 12.12 Synchronized Block
      13. 12.13 Coordination Among Threads
      14. 12.14 Problem: Car Dealer Application
      15. 12.15 Threads Life
      16. 12.16 Concurrent Programming Packages
      17. 12.17 The Concurrent Package
      18. 12.18 The Concurrent.atomic Package
      19. 12.19 Problem: Random Strings Generator
      20. 12.20 The Concurrent.locks Package
      21. 12.21 Summary
      22. Key Terms
      23. Review Questions
      24. Exercises
    2. Chapter 13: Processing Byte and Object Streams
      1. 13.1 Introduction
      2. 13.2 The File Class
      3. 13.3 Filtering File Names
      4. 13.4 Filtering Absolute File Paths
      5. 13.5 Types of Input Streams
        1. 13.5.1 Reading files as bytes
        2. 13.5.2 Reading files into byte array
        3. 13.5.3 Reading strings as bytes
      6. 13.6 Types of Output Streams
        1. 13.6.1 Writing to files as bytes
        2. 13.6.2 Writing to byte array as bytes
      7. 13.7 Problem: Copy Files as Bytes
      8. 13.8 Processing Primitive Data Types
      9. 13.9 Problem: Generating Students Mark List
      10. 13.10 Serializing Objects
      11. 13.11 Problem: Generating Students’ Mark List – Revisited
      12. 13.12 Transient Variables
      13. 13.13 Summary
      14. Key Terms
      15. Review Questions
      16. Exercises
    3. Chapter 14: Processing Character Streams and NIO
      1. 14.1 Introduction
      2. 14.2 Types of Readers
        1. 14.2.1 Reading files as characters
        2. 14.2.2 Problem: Word counting using filereader
        3. 14.2.3 Reading files as lines
        4. 14.2.4 Problem: Text index generator
      3. 14.3 Types of Writers
        1. 14.3.1 Writing characters to file
        2. 14.3.2 Problem: Copy files using filewriter
        3. 14.3.3 Writing lines to files
      4. 14.4 Writing to and Reading from Pipes
      5. 14.5 Formatted Printing
      6. 14.6 Random Access File
      7. 14.7 Converting Bytes to Characters
      8. 14.8 File Processing Using NIO
      9. 14.9 Reading Data from Buffer
      10. 14.10 Writing Data to Buffer
      11. 14.11 Copying Files
      12. 14.12 Locking Files
      13. 14.13 Summary
      14. Key Terms
      15. Review Questions
      16. Exercises
  12. PART V — JAVA GUI PROGRAMMING
    1. Chapter 15: Graphics Programming
      1. 15.1 Introduction
      2. 15.2 Swing Components and Containers: Overview
      3. 15.3 Frames and Panels
      4. 15.4 Drawing Shapes Using Graphics Context
      5. 15.5 Drawing Strings and Lines
      6. 15.6 Problem: Multiline Generation
      7. 15.7 Drawing Rectangles
      8. 15.8 Problem: Random Rectangle Generator
      9. 15.9 Drawing Circles and Ellipses
      10. 15.10 Drawing Arcs
      11. 15.11 Drawing Polygons and Polylines
      12. 15.12 Displaying Images
      13. 15.13 Problem: Threaded Blinking Balls
      14. 15.14 Painting Using JApplet
      15. 15.15 Java 2D Graphics
      16. 15.16 Drawing Lines and Curves
      17. 15.17 Drawing Rectangle, Ellipses and Arcs
      18. 15.18 Filling with Color, GradientPaint and TexturePaint
      19. 15.19 Drawing Arbitrary Shapes
      20. 15.20 Coordinate Transformations
      21. 15.21 2D Clipping
      22. 15.22 Affine Transformations on Images
      23. 15.23 Summary
      24. Key Terms
      25. Review Questions
      26. Exercises
    2. Chapter 16: GUI Development Using JFrame
      1. 16.1 Introduction
      2. 16.2 Creating Labels and Buttons
      3. 16.3 Problem: Digital Clock as Jlabel
      4. 16.4 Basics of Event Handling
      5. 16.5 Layout Managers
        1. 16.5.1 FlowLayout
        2. 16.5.2 BorderLayout
        3. 16.5.3 GridLayout
        4. 16.5.4 Multiple layouts using JPanel
        5. 16.5.5 BoxLayout and box
      6. 16.6 Event Handling Revisited
      7. 16.7 Problem: Color Label Application
      8. 16.8 Problem: Throw Ball Application
      9. 16.9 Creating Text Field and Text Area
      10. 16.10 Problem: File Lister
      11. 16.11 Problem: Numeric Text Field
      12. 16.12 Problem: Text Copy Cat
      13. 16.13 Creating CheckBox, RadioButton, ComboBox and List
        1. 16.13.1 CheckBoxes
        2. 16.13.2 Radio buttons
        3. 16.13.3 Combo boxes
        4. 16.13.4 Lists
      14. 16.14 Dialog Windows
      15. 16.15 Choosing File Names
      16. 16.16 Choosing Colors
      17. 16.17 Displaying Messages
        1. 16.17.1 Message dialogs
        2. 16.17.2 Confirm dialogs
        3. 16.17.3 Option dialogs
        4. 16.17.4 Input dialogs
      18. 16.18 Problem: Designing Course Registration Form
      19. 16.19 Creating Editor Pane and Text Pane
      20. 16.20 Creating Slider
      21. 16.21 Designing Tabbed Pane
      22. 16.22 Handling Menu
      23. 16.23 Table Handling
      24. 16.24 Creating Custom Swing Components
      25. 16.25 Summary
      26. Key Terms
      27. Review Questions
      28. Exercises
    3. Chapter 17: GUI Development Using JApplet
      1. 17.1 Introduction
      2. 17.2 Applet Advantages and Restrictions
      3. 17.3 Creating and Running Applets
        1. 17.3.1 Running applets with web browser
        2. 17.3.2 Running applets with appletviewer
        3. 17.3.3 Running applets with java interpreter
      4. 17.4 Creating GUI Components Inside Applets
      5. 17.5 Applet Input Parameters
      6. 17.6 Images in Applets
      7. 17.7 Timers Firing ActionEvent
      8. 17.8 Playing Audio Clips
      9. 17.9 Handling Mouse Event
      10. 17.10 Handling Hyperlink Event
      11. 17.11 Building Archives Using JAR
      12. 17.12 Signing Applets
      13. 17.13 Problem: Accessing Websites from WWW
      14. 17.14 Summary
      15. Key Terms
      16. Review Questions
      17. Exercises
  13. Appendix A
  14. Appendix B
  15. Appendix C
  16. Acknowledgements
  17. Copyright
  18. Back Cover

Product information

  • Title: JAVA Programming
  • Author(s): K. Rajkumar
  • Release date: May 2013
  • Publisher(s): Pearson India
  • ISBN: 9789332517875