ISBN 9789350237557,Java for Beginners

Java for Beginners



Shroff Publishers & Distributors Pvt Ltd

Publication Year 2008

ISBN 9789350237557

ISBN-10 9350237555

Paper Back

Edition 2nd
Number of Pages 576 Pages
Language (English)

Programming languages

This is highly user friendly book on Java programming. It covers the Java Platform TM Standard Edition 7 JDK. No knowledge of programming is assumed while writing this book. Anyone who knows how to operate the computer and has used at least one Windows based application like Word or Excel can read and understand this book. It strikes perfect balance between theory and practice. It can be used as text-book as well as reference book. Every chapter includes Drill Problems with Answers, Exercises, and Programming Problems. Starting from the basics of Java programming it covers the advanced features like multithreading, graphic user interface, image processing, and computer game programming. Full Java compiler is given on the CD so that reader can immediately compile and execute the programs. Appendix includes the detailed procedure of installation of Java compiler.

The Topics Covered in the Book
Brief History Of Java
Actual Machine And Virtual Machine
Compiled And Interpreted Languages
Type Conversion And Casting
Data Types
Control Statements
User-Defined Methods
Method Overloadng
Method Overriding
Object-Oriented Programming
Classes And Objects
Exception Handling
Collections Framework
Utility Classes
Gui Based Applications
Java Projects

Contents of the CD-Rom
Java Compiler for Java PlatformTM Standard Edition 7 JDK.
Bonus chapter named Java Projects which contains eight Java projects.
All the source code used in this book.
Images in all formats. Start writing image processing programs now.

About the Author
Shirish Chavan did his MSc in Theoretical Physics from Shivaji University, Kolhapur, Maharashtra. He is a writer, an orator, a scientist, a teacher, and a software consultant. As a writer he has written nine books on computers. As a scientist he is having one discovery and two inventions to his credit. He runs a software consultancy firm. He produces learning material for the students through Chavan Learning Systems.

Table of Contents
1: Welcome to Java
1.1 Brief History of Programming Languages
1.2 Brief History of Java
1.3 Programs, Software, and Operating System
1.4 Machine Language and Assembly Language
1.5 The Procedural Languages
1.6 Object-Oriented Languages
1.7 Terminology in Computers
1.8 Actual Machine and Virtual Machine
1.9 Compiled and Interpreted Languages
1.10 Our Very First Java Program
1.11 Java is Free Form Language
1.11.1 Inserting White Spaces
1.11.2 Concatenation of Strings
1.12 Using the Methods print ( ) and println ( )
1.12.1 Difference between print ( ) and println ( ) methods
1.12.2 Variable as Argument to println ( ) Method
1.12.3 Operator Overloading
1.13 Escape Sequences
1.14 Salient Features of Java
1.15 Compile-Time and Run-Time Environments
1.16 Expression
Programming Problems
2. Fundamentals of Java
2.1 Tokens
2.2 User-defined Identifiers
2.3 Keywords
2.4 Primitive or Simple Data Types
2.4.1 Integer Data Types
2.4.2 Floating Point Data Types
2.4.3 Character Data Types
2.4.4 Boolean Data Types
2.5 Literals
2.5.1 Integer Literals
2.5.2 Floating Point Literals
2.5.3 Character Literals
2.5.4 Boolean Literals
2.5.5 String Literals
2.6 Using Variables
2.6.1 Variable Declaration
2.6.2 Assigning Values to Variables
2.6.3 Initializing the Variables
2.7 Using String Objects
2.8 Type Conversion and Casting
2.8.1 Widening and Narrowing Primitive Conversions
2.8.2 Explicit Type Conversion Using Cast Operator
2.8.3 Automatic Data Type Promotions
2.9 Symbolic Constants
2.10 Window Based Input and Output
2.10.1 Window Based Output
2.10.2 Window Based Input
2.10.3 Window Based Input and Output
2.10.4 Default Text in Input-box
2.11 Hexadecimal, Decimal, Octal, and Binary Systems of Numbers
2.12 Variables and Memory: Inside Story
Programming Problems
3. Operators
3.1 Operators
3.2 Arithmetic Operators
3.2.1 Primer
3.2.2 Basic Arithmetic Operators
3.2.3 Modulus Operator
3.2.4 Increment and Decrement Operators
3.2.5 Arithmetic Assignment Operators
3.2.6 Arithmetic Expressions and Parentheses
3.3 Bitwise Operators * * *
3.3.1 Primer
3.3.2 Bitwise Logical Operators
3.3.3 Shift Operators
3.3.4 Assignment Operators
3.4 Relational Operators
3.5 Boolean Logical Operators
3.6 The Assignment Operator
3.7 Precedence of Operators
3.8 Concept of Computer-Control and Flowcharts
3.9 Activity Diagrams
3.10 Program Design Language (PDL)
Programming Problems
4. Control Statements
4.1 Introduction
4.2 Selection Statements
4.2.1 if-else Statement
4.2.2 switch Statement
4.3 Iteration Statements
4.3.1 while Statement
4.3.2 Using continue Statement
4.3.3 Using break Statement
4.3.4 Beware of Infinite Loops
4.3.5 do-while Statement
4.3.6 for Statement
4.3.7 Nesting of Loops
4.4 Jump Statements
4.4.1 break Statement
4.4.2 continue Statement
4.4.3 return Statement
4.5 Methods toUpperCase ( ) and equals ( )
4.6 Simple Programs
4.6.1 Summation of 1 to 100 Numbers using while Statement
4.6.2 Summation of 1 to 100 Numbers using do-while Statement
4.6.3 Summation of 1 to 100 Numbers using for Statement
4.6.4 Summation of 1 to N Numbers
4.6.5 Factorial of a Number
4.6.6 Generating the Fibonacci Sequence
4.6.7 To Determine Whether a Given Number is Prime or Not
4.6.8 Computing the Sine Function
Programming Problems
5. User-Defined Methods
5.1 Lesson from Structured Programming
5.2 Creating a Simple User-Defined Method
5.3 Variables Can Be Used as Arguments
5.4 Arguments are Passed by Value
5.5 Local Variables
5.6 Overloaded Methods
5.7 Promotion of Data Types of Arguments
5.8 Chain of Method-Calls
5.9 Recursion
5.9.1 Summation of Numbers Using Recursion
5.9.2 Factorial Using Recursion
5.9.3 Towers of Hanoi
5.9.4 Merits and Demerits of Recursion
Programming Problems
6. Basic Principles of Object-Oriented Programming
6.1 What is Object-Oriented Programming?
6.2 Creating Objects from Classes
6.3 Operator new and Constructors
6.4 Using a Constructor
6.5 Using Arguments in Methods
6.6 Using this Operator
6.7 Assigning Object Reference Variable to Another
6.8 static Variables
6.9 Deleting the References to Objects and Garbage Collection
6.10 Overloaded Constructor
6.11 static Methods
6.12 Access Specifiers
6.12.1 Access Specifiers for Classes and Interfaces
6.12.2 Access Specifiers for Variables and Methods
Programming Problems
7. Inheritance, Packages, and Interfaces
7.1 What is This Inheritance?
7.2 Inheritance and Constructors
7.3 Types of Inheritance
7.4 Overriding the Members
7.5 Dynamic Method Dispatch
7.6 final Members and Classes
7.7 Abstract Methods and Classes
7.8 Packages
7.9 Creating a Package
7.10 Using Two Packages
7.11 Scopes of Members
7.12 Package Notation
7.13 Interfaces
7.14 Interface can be Extended
7.15 Interface Must Be Implemented
7.16 Using a Variable of Type Interface
7.17 Computing the Area of Shapes Using Interface
Programming Problems
8. Arrays, Strings, Enumeration, and Exception Handling
8.1 Welcome to Arrays
8.2 One Dimensional Arrays
8.3 Assigning One Array Variable to Another
8.4 Alternative Syntax for Arrays
8.5 Initialization of Array
8.6 Length of Array
8.7 Two-Dimensional and Multidimensional Arrays
8.8 Using Array of Strings
8.9 For-Each Version of for Loop
8.10 Passing Command Line Arguments to Method main ( )
8.11 Using Strings
8.12 Indexing of Characters in a String
8.13 Creating Strings Using String Class
8.14 Concatenation of Strings
8.15 Methods of String Class
8.16 Difference Between String, StringBuffer, and StringBuilder
8.17 Creating Strings of Type StringBuffer
8.18 Methods of StringBuffer Class
8.19 Welcome to Enumerations
8.20 Methods of Enumeration Class
8.21 Enumeration and switch Statement
8.22 Using Constructors, Methods, and Instance Variables with Enumeration
8.23 Debugging a Program
8.24 Using a try-catch Framework
8.25 Using the Multiple catch Blocks
8.26 Manually Throwing the Javas Built-In Exceptions
8.27 Throwing the Custom Made Exceptions
8.28 Using the Keyword throws
8.29 Variable Length Arguments: Varargs
Programming Problems
9. Multithreading, Autoboxing, Generics, and Collections Framework
9.1 Welcome to Threads
9.2 Experimenting With Main Thread
9.3 Creating a New Thread Using the Class Thread
9.4 Creating a New Thread Using the Interface Runnable
9.5 Overloaded Constructor Thread ( )
9.6 Creating Multiple Threads
9.7 Methods setPriority ( ), isAlive ( ), and join ( )
9.8 Problem of a Shared Resource
9.9 Synchronization
9.10 Using suspend ( ), resume ( ), and stop ( )
9.11 Using wait ( ), notify ( ), notifyAll ( ), and interrupt ( )
9.12 Modern Way of Controlling the Threads
9.13 Type Wrappers
9.14 Autoboxing and Auto-unboxing
9.15 Generics
9.15.1 Welcome to Generics
9.15.2 Using Constructor in Generic Class
9.15.3 Using a Method Whose Return Type is
9.15.4 A Generic Class with Two Type Parameters
9.15.5 Bounded Types
9.16 Before Collections Framework
9.16.1 Class Dictionary
9.16.2 Class Hashtable
9.16.3 Class Properties
9.16.4 Class Vector
9.16.5 Class Stack
9.17 Collections Framework
9.17.1 Class ArrayList
9.17.2 Class HashSet
9.17.3 Class TreeSet
9.17.4 Class HashMap
Programming Problems
10. Utility Classes and Files
10.1 Class Math
10.1.1 Exponential Methods
10.1.2 Transcendental Methods
10.1.3 Rounding Method
10.1.4 Miscellaneous Methods
10.2 Class StringTokenizer
10.3 Class Date
10.4 Class Calendar
10.5 Class GregorianCalendar
10.6 Class Random
10.7 Class Formatter
10.7.1 Basics of Formatting Using Class Formatter
10.7.2 Formatting Time and Date
10.7.3 Using the Minimum Field Width Specifier
10.7.4 Using the Precision Specifier
10.7.5 Using the Format Flags
10.8 Files Handling Utilities in Java
10.9 Class File
10.10 Class FileReader
10.11 Class FileWriter
Programming Problems
11. Applets and Graphics
11.1 Welcome to Applets
11.2 How Applet Works?
11.3 Old and New Classes in GUI
11.4 Colors, Status Window, Document Base, and Code Base
11.5 Using Desired Font
11.6 Welcome to Graphics
11.7 Drawing the Straight Lines
11.8 Drawing the Rectangles
11.9 Drawing Ellipses and Circles
11.10 Drawing the Arcs
11.11 Drawing Polygons
11.12 Class Color
11.13 Animation
11.14 Applet Myclock
11.15 APPLET Tag
Programming Problems
12. GUI Based Applications: Part I
12.1 Welcome to GUI Based Applications
12.2 Placing Buttons on Frame, Layout Manager and FlowLayout
12.3 Using the Layout Manager GridLayout
12.4 Using the Layout Manager BorderLayout
12.5 Using the Absolute Positioning of Components
12.6 Handling the Events Generated by Buttons
12.6.1 Using Two Different Classes
12.6.2 Putting All the Code in a Single Class
12.7 GUI on Applets
12.7.1 Separate Classes for Creating a GUI and Handling the Events
12.7.2 Single Class for Creating a GUI and Handling the Events
12.8 Using Labels
12.9 Using Radio Buttons
12.9.1 Using a Single Button Group
12.9.2 Using Two Button Groups
12.10 Using Check Boxes
12.11 Using Combo Boxes
Programming Problems
13. GUI Based Applications: Part II
13.1 Using Text Fields
13.2 Using Sliders
13.3 Using Text Areas and Scroll Panes
13.4 Using Dialog Boxes
13.5 Using Inner Class
13.6 Using Anonymous Inner Class
13.7 Using the Menus
13.7.1 Creating a Simple Menu
13.7.2 Using Hot Keys or Mnemonics in Menu
13.7.3 Creating a Professional Menu
13.8 Using Images
13.9 Using Sound Clips
Programming Problems
14. Java Projects .1-72(CD)
14.1 Creating an Abstract Image 1(CD)
14.2 Roating an Image Through 90 Degrees 7(CD)
14.3 Creating a Negative of an Image24(CD)
14.4 Converting a Colored Image into a Black and White Image 27(CD)
14.5 Drawing a Line Using a Technique of Fractals 31(CD)
14.6 To Simulate a Car Race - A Computer Game 33(CD)
14.7 To Simulate a Russian Roulette - A Computer Game 39(CD)
14.8 To Simulate a Dark Horse - A Computer Game 54(CD)
Appendix A
Appendix B
What is on the CD