Contents

Preface

List of Programs

List of Boxes

List of Figures

List of Tables

Chapter 1: Introduction

1.1 A Brief History of Java

1.2 Why Is Java Popular for the Internet?

1.3 Features of Java

1.3.1 Simple

1.3.2 Secure

1.3.3 Portable

1.3.4 Object oriented

1.3.5 Robust

1.3.6 Multi-threaded

1.3.7 Interpreted

1.3.8 Architecture neutral

1.3.9 Distributed

1.4 How Java Programs Run

1.5 Advantages and Disadvantages of an Interpreted Language

1.6 Java Applets and Applications

1.7 Advantages of Java Technology

1.8 Java Platform

1.9 Java Development Kit

1.10 How to Run Simple Java Programs

1.10.1 How to organize our computer for command prompt operation

1.10.2 How to run a simple program in command prompt environment

1.10.3 How to run programs in integrated development environments

Keywords

RuleBook

Review Questions

Chapter 2: Object Orientation an Introduction

2.1 Programming Languages Before Object Orientation Became Popular

2.2 Features of Object-Oriented Language

2.2.1 Encapsulation

2.2.2 Data hiding

2.2.3 Inheritance

2.2.4 Polymorphism

2.2.5 Message passing

2.3 The Benefits of OOP

2.3.1 Software reusability

2.3.2 Code sharing

2.3.3 Rapid prototyping

2.3.4 Information hiding

Keywords

Review Questions

Chapter 3: Java Language Basics

3.1 Introduction

3.2 Java Program Structure

3.3 Basic Building Blocks

3.3.1 Comments

3.3.2 Character set

3.3.3 Constants

3.4 Variables

3.5 Data Types

3.5.1 Numeric data types

3.5.2 Non-numeric data types

3.5.3 Declarations of variables

3.6 Operators

3.6.1 Arithmetic operators

3.6.2 Relational operators

3.6.3 Logical operators

3.6.4 Bit-wise operators

3.6.5 Shift operators

3.6.6 Assignment operators

3.6.7 Other (special) operators

3.7 Expressions

3.7.1 Arithmetic expressions

3.7.2 Arithmetic expressions with single operand

3.7.3 Arithmetic expressions with two operands

3.7.4 General arithmetic expressions

3.7.5 Logical expressions

3.7.6 Assignment expressions

3.7.7 Type char in assignment

3.8 Typecasting

3.9 Keyword Final

3.10 Statements

3.10.1 Expression statements

3.10.2 Declaration statement

3.10.3 Flow control statements

3.10.4 Empty statement

3.10.5 Labelled statement

3.11 Description of Very Simple Java Program

3.12 End of Chapter Programs

3.12.1 Relational expression

3.12.2 Study of special characters

3.12.3 Truncating a real number

3.12.4 A straight line

3.12.5 Keyword final

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 4: Control Structures

4.1 Simple If Statement

4.2 If-Else Statement

4.3 Switch-Case Statement

Advance Note

Keywords

RuleBook

Review Questions

Exercises

Chapter 5: Loops

5.1 for Loop

5.2 while Loop

5.3 do-while Loop

5.4 break and continue

5.4.1 break statement

5.4.2 continue statement

5.5 Comparison of all the Three Constructs

5.6 End of Chapter Programs

5.6.1 Fibonacci numbers

5.6.2 Compound interest

5.6.3 for loop control variable

5.6.4 Java is great!

5.6.5 cv can be a character

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 6: Functions

6.1 Functions in Java

6.1.1 Syntax of methods

6.2 Recursive Functions

6.3 Parameter Passing

6.3.1 Simple data types as parameters

6.3.2 Objects as parameters

6.4 Method swap

6.5 In-built Methods or Library Methods

6.6 End of Chapter Programs

6.6.1 Method pow()

6.6.2 Method Math.atan2()

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 7: Arrays

7.1 Arrays in Java

7.2 Creating an Array

7.3 Array Index Checking

7.4 Multi-Dimensional Arrays

7.4.1 Matrix addition

7.4.2 Matrix multiplication

7.5 Enhanced for Loop

7.6 End of Chapter Programs

7.6.1 Array index out of bound

7.6.2 Binary search

7.6.3 Linear search

7.6.4 Checking for duplicate

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 8: Introducing Classes

8.1 Class Fundamentals

8.1.1 The general form of a class

8.1.2 A simple class

8.2 Declaring and Creating Objects

8.3 Accessing Members

8.4 Access Control Parameters: Public and Private

8.5 Introducing Methods

8.6 Methods with Parameters

8.7 Methods Returning a Value

8.8 Constructors

8.9 System-Supplied Constructor

8.10 Default Constructor

8.11 Keyword this

8.12 Garbage Collection

8.13 The finalize() Method

8.14 Overloading Methods and Constructors

8.15 Using Objects as Parameters

8.16 Keyword Static

8.16.1 Static variables

8.16.2 Static methods

8.17 Description of Simple Java Program

8.18 End of Chapter Programs

8.18.1 Initializing an object is necessary

8.18.2 A non-static method can access private instance variables

8.18.3 Private variables are not accessible outside the class

8.18.4 Use of this keyword

8.18.5 Keyword static not allowed for local variables

8.18.6 Class Point

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 9: Wrapper Classes

9.1 Introduction

9.2 Class Byte

9.3 Float

9.4 Boolean

9.5 Character

9.6 Autoboxing and Unboxing Principle

9.7 End of Chapter Programs

9.7.1 Java identifier start

9.7.2 Method valueOf()

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 10: Strings

10.1 Introduction

10.2 Declaring and Constructing a String

10.3 Reading a String

10.4 Writing a String

10.5 Copying One String into Other

10.6 Comparing Strings

10.7 Other Operations on Strings

10.7.1 Testing for contents

10.7.2 Changing the case

10.7.3 Methods valueof() and toString()

10.7.4 Concatenation of strings

10.8 Sorting Strings

10.9 StringBuffer

10.9.1 How to modify strings using StringBuffer

10.10 Class Vector

10.11 End of Chapter Programs

10.11.1 Reading a string from console

10.11.2 Comparison operators == does not work on strings

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 11: Simple Input/Output

11.1 Concepts of Streams, Stream Classes

11.2 Character Stream Classes

11.3 Writing to the Screen

11.4 Simple Formatting

11.5 Formatting with printf

11.6 Reading the Data

11.7 Reading Strings

11.8 Reading Data

11.9 Class Scanner

11.10 StreamTokenizer

11.11 Hierarchies of Character-Based i/o Classes

11.12 Hierarchies of Byte-Oriented i/o Classes

11.13 End of Chapter Programs

11.13.1 Using class InputStreamReader

11.13.2 Reading integer

11.13.3 Reading into a character array

11.13.4 Formatted output

RuleBook

C++ Corner

Keywords

Review Questions

Exercises

Chapter 12: Inheritance

12.1 Inheritance Basics

12.2 Member Access and Inheritance

12.3 Keyword super

12.3.1 Use of super in sub-class constructor

12.3.2 Use of super in referencing a super-class variable

12.4 Use of this in Sub-Class Constructor

12.5 Creating a Multi-Level Hierarchy

12.5.1 Keyword protected

12.6 Method overriding

12.7 Using final in Inheritance

12.7.1 Using final with a class

12.7.2 Using final with a method of a super-class

12.8 Introducing Interface

12.8.1 Defining an interface

12.8.2 Implementing interfaces

12.8.3 Variables in interfaces

12.9 Abstract Methods and Classes

12.10 Collection of Programs

12.10.1 private of super not accessible

12.10.2 This program proves that default acts as public

12.10.3 Is super always needed in sub-class constructor?

12.10.4 A final class cannot be extended

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 13: Graphics

13.1 Introduction

13.2 Frame

13.3 Drawing a Line

13.4 Drawing a Rectangle

13.5 Drawing a Point

13.6 Drawing Circles

13.7 Introducing Colours

13.8 Designing a Fabric

13.9 Simple Animation

13.10 End of Chapter Programs

13.10.1 Thick point by other methods

Keywords

C++ Corner

Review Questions

Exercises

Chapter 14: Collection of Academic Programs

14.1 Prime Numbers

14.1.1 Sieve of Eratosthenes

14.1.2 Prime numbers: A more efficient method

14.2 Date, Time, and Calendar

14.2.1 Class Date

14.2.2 Method getTime() from class Date

14.2.3 Class GregorianCalendar

14.2.4 Incrementing a date

14.3 Matrix

14.3.1 Matrix addition

14.3.2 Matrix multiplication

14.4 Handling Complex Numbers

14.5 Astrology and Numerology

14.5.1 Astrology

14.5.2 Numerology

14.6 Playing Cards

14.6.1 Shuffling of cards I

14.6.2 Generate a fresh deck of cards

14.7 Searching and Sorting

14.7.1 Selection sort

14.7.2 Quick sort

14.7.3 Bubble sort

Exercises

Chapter 15: Miscellaneous Topics

15.1 Packages

15.1.1 Def ining and using packages

15.1.2 Static import

15.2 Command Line Arguments

15.3 Inner and Outer Classes

15.4 BigInteger

15.5 Enumeration

15.6 Labelled break and Labelled Continue

15.6.1 Labelled break

15.6.2 Labelled continue

15.7 Operators Revisited

15.7.1 Conditional operator (? :)

15.7.2 Operator instanceof

15.7.3 Operator >>>

15.8 Interface Cloneable

15.8.1 Method clone()

15.9 Generics

15.9.1 Generic types

15.9.2 Generic methods

15.10 Guidelines for Forming Identifiers

15.11 Parameter Passing Re-visited

15.12 Dynamic Data Structures

15.12.1 Linked list

15.12.2 Binary search tree

15.13 Package Java.util

15.13.1 Arrays

15.13.2 Class BitSet

15.14 Class Runtime

15.14.1 Methods freeMemory() and totalMemory()

15.15 Class System: Time Delay Routine

15.16 Assertion

15.17 Description of Advanced Java Program

15.18 The Untold Story: Java Criticized

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 16: Inheritance Revisited

16.1 Class Object

16.2 Multiple Inheritance

16.3 Polymorphism

16.3.1 A super-class variable can reference a sub-class object

16.3.2 Polymorphism in action

16.4 Dynamic Method Dispatch

16.5 Collection of Programs

16.5.1 Sub-class reference cannot be assigned a super-class value

16.5.2 Arrays of dissimilar elements

RuleBook

C+ + Corner

Review Questions

Exercises

Chapter 17: Files

17.1 Why Files?

17.2 File Classification

17.3 Class File

17.4 Text Files

17.5 Formatted File Input

17.6 Reading File with Format-Free Data

17.7 Binary Files

17.8 Files for Objects

17.9 Random Access File

17.10 Object Serialization

17.11 End of Chapter Programs

17.11.1 Large binary file

17.11.2 Large text file

17.11.3 List of files

17.11.4 Reading matrices from binary files

17.11.5 Listing all the files including those in the sub-folders

Keywords

Review Questions

Chapter 18: Multi-threaded Programming

18.1 What are Threads?

18.2 Why Use Threads?

18.3 Creating and Running a Thread

18.4 Creating Multiple Threads

18.5 Life Cycle of a Thread

18.6 Implementing Runnable Interface

18.7 Thread Priority and Thread Scheduling Policy

18.8 Synchronization

18.8.1 Synchronized methods

18.8.2 Synchronized statements

18.8.3 Methods wait(), notify(), and notifyAll()

18.8.4 Method join()

18.9 Timer and TimerTask

Keywords

RuleBook

Review Questions

Exercises

Chapter 19: Exception Handling

19.1 Why Use Exception Handling

19.2 Types of Exceptions

19.3 Checked and Unchecked Exceptions

19.4 Exception Handling Constructs

19.5 Keyword finally

19.6 Throw Statement

19.7 Multiple Catch Blocks

19.8 Collection of End of Chapter Programs

19.8.1 Clause finally

19.8.2 Number format exception

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 20: Java Applets

20.1 Applet Basics

20.2 The Applet Class

20.3 Applet Architecture

20.4 Applet Life Cycle

20.5 Comparison of Applet and Application

20.6 Setting Font and Changing Style, Size, Type, Foreground and Background Colour

20.7 Using Graphics Methods in Applets

20.8 Colours and Applets

20.9 Images in Applet

20.10 Sound in Applets

20.11 Applet Tag Attributes

20.12 JAR Files

20.13 Introduction to HTML

Keywords

RuleBook

C++ Corner

Review Questions

Exercises

Chapter 21: Event Handling And AWT

21.1 Abstract Window Toolkit

21.1.1 Using Button

21.1.2 Using TextField

21.1.3 Using checkbox

21.1.4 Using radio button

21.1.5 Using canvas

21.2 Event Handling

21.2.1 Delegation event model

21.2.2 Event classes and event listener interfaces

21.2.3 KeyEvent

21.2.4 Mouse events

21.2.5 Adapter classes

21.2.6 Virtual key code constants

Keywords

RuleBook

Review Questions

Exercises

Chapter 22: Introduction to Swing

22.1 JFrame

22.2 JOptionPane for (Output) Message

22.3 Input Dialog JOptionPane

22.4 Class JButton

22.5 Class JLabel

22.6 JCheckBox

22.7 Introduction to JRadioButtons

22.8 Introduction to Class Canvas

22.9 Class JTextField

22.9.1 Simple demo

22.9.2 Finding a square of a number

22.10 JTextArea

22.11 JMenu

22.12 JFileChooser

22.13 JComboBox

22.14 Layout Manager

22.14.1 BorderLayout

22.14.2 BoxLayout

22.14.3 GridLayout

22.15 Using Borders

22.16 Java Foundation Classes

Keywords

RuleBook

Review Questions

Exercises

Chapter 23: Collection Framework

23.1 Collection Interface

23.2 List Interface

23.3 ArrayList

23.4 LinkedList

23.5 Interface Set

23.5.1 Iterator

23.6 TreeSet

23.7 HashSet

23.8 Interface Map

23.9 HashMap

23.10 TreeMap

23.11 Hashtable

23.12 Algorithms

23.12.1 Sorting

23.12.2 Algorithm shuffle

23.12.3 Binary search

23.13 HashMap

23.14 Enhanced For Loop

Keywords

RuleBook

Review Questions

Exercises

Chapter 24: Multimedia Experience

24.1 Images

24.1.1 Introducing image

24.1.2 Converting image to an array

24.1.3 Processing image

24.1.4 Study of transparency

24.1.5 Subtitles

24.2 Sound

24.2.1 Sound in applications

24.2.2 A musical keyboard

24.3 Complete Multimedia Experience

Keywords

Review Questions

Exercises

Chapter 25: Moving From C++ to Java

25.1 Part I: Comparing keywords

25.1.1 Keywords

25.2 Part II: Differences as a Programming Language

25.2.1 Facilities in C++ missing in Java

25.2.2 Facilities in Java not present in C++

25.3 C++ to Java Through Programs

25.3.1 Exercise one

25.3.2 Exercise two

25.3.3 Exercise three

25.3.4 Exercise four

25.3.5 Exercise five

25.3.6 Exercise six

25.4 Rules for C++ to Java Conversion

Chapter 26: Collection of Programs

26.1 Projectile

26.2 Wall Clock

26.3 Drawing Ellipses

26.4 Area of Circle by Monte Carlo Method

26.5 Display of Binary Tree

26.6 Drawing with Data from a File

26.7 Animation

26.8 Graphical Display of Bubble Sort

26.9 Astrology: Strength of a Horoscope

26.9.1 Strength of planets located in different signs

26.9.2 Strength of planets depending on the position

26.10 Freehand Drawing

26.11 Sudoku I

26.12 Sudoku II

26.13 Moon Revolves Around Earth

26.14 Astronomy: Retrograde Motion

Appendices

Appendix A: RuleBook

Appendix B: Keywords

Appendix C: Operators

Appendix D: List of Important Packages

Appendix E: Mini projects

AE. 1 Chess Clock

AE. 2 Rolling board

AE. 3 Kaun Banega Karodpati

AE. 4 Exam master

AE. 5 Game of Business

AE. 6 Game: Snake II

AE. 7 Game: Snake and ladder

AE. 8 Game of Contract Bridge

AE. 9 Java IDE in Java

AE. 10 Game of chess

Glossary

Bibliography

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.138.195