Contents

About the Authors

Preface

How to Use This Book and Web Resources

1 Object-oriented Programming Basics

1.1 Introduction

1.2 Programming Concepts

1.3 Programming Paradigms

1.3.1 Structured Programming Paradigm

1.3.2 C: A Workhorse that Works Well

1.3.3 Where is the Problem?

1.3.4 Object-oriented Programming Paradigm

1.4 History and Development of Object-oriented Languages

1.4.1 C++

1.4.2 Java

1.4.3 C#

1.5 Software Development Methodologies

1.6 Need for Objects

1.7 Object-oriented Language Features

1.7.1 Object-based Programming

1.7.2 Object-oriented Programming

1.8 Definition of OOP Language Classes and Objects

1.8.1 Attributes and Behaviours of Objects

1.8.2 Class

1.8.3 Encapsulation

1.8.4 Data Hiding/Data Abstraction

1.8.5 Function Overloading

1.8.6 Operator Overloading

1.9 Extendibility and Reusability of OOP Paradigms

1.10 Extending/Deriving New Classes

1.10.1 Containment: Class Within a Class – Container Class

1.10.2 Inheritance and Class Hierarchy

1.10.3 Single and Multiple Inheritances

1.11 Virtual Functions

1.12 Run-time Polymorphism and Dynamic Data Binding

1.13 Class as Abstract Data Type (ADT)

1.14 Standard Template Library (STL)

1.15 OOPS – Object-oriented Programming and Systems

1.16 Object-oriented Analysis and Design (OOAD)

1.17 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Solutions to Objective Questions

2 Object Modelling

2.1 Introduction

2.2 Object Model

2.3 Object-oriented Design

2.4 Classes and Objects

2.4.1 Class

2.4.2 Notations and Meta Models

2.4.3 Mandatory Profile

2.4.4 Meta Data – Meta Class

2.4.5 Constraints

2.4.6 Object Creation

2.4.7 Garbage Collection

2.5 Object Properties

2.6 Links

2.7 Class Diagrams

2.8 Class Hierarchy

2.8.1 Associations

2.8.2 Hierarchies with Interdependent Classes

2.8.3 Hierarchies with Independent Classes

2.9 Object Diagrams

2.10 Communications and Message Passing

2.11 Polymorphism

2.12 Abstract Class

2.13 Concrete Class

2.13.1 OOPS – A Case Study in Object Modelling

2.14 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

3 Extensibility and Reusability – Inheritance at Work

3.1 Extendibility and Reusability of OOP Paradigm

3.2 Extending/Deriving New Classes

3.2.1 Containment: Class within a Class – Container Class

3.2.2 Inheritance and Class Hierarchy

3.2.3 Generalization vs Specialization

3.3 Overriding Base Class Functions

3.4 Overloading

3.5 Single and Multiple Inheritances

3.6 Virtual Inheritance

3.7 Problems with Multiple Inheritance

3.8 Interface

3.9 Access Specifiers in Inheritance

3.10 Run-time-type Information – RTTI

3.11 Virtual Functions

3.12 Pure Virtual Functions

3.13 Run-time Polymorphism and Dynamic Data Binding

3.14 Class as Abstract Data Type

3.15 Separation of Behaviour and Implementation

3.16 Decoupling

3.17 Standard Template Library

3.18 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

4 Dynamic Modelling

4.1 Introduction to Static and Dynamic Modelling

4.2 Lifetime of an Object

4.3 Unified Modelling Language – A Tool for OOAD

4.3.1 Overview of UML

4.3.2 Classification of UML Diagrams

4.4 User Requirements – Use Cases

4.5 Architecture and Domain: What Are They?

4.5.1 Architecture

4.5.2 Domain

4.6 Sequence Diagram

4.7 Collaboration (Communication) Diagram

4.8 Events and State

4.8.1 Activity/Action and Operations

4.8.2 Nested State Diagrams

4.9 Activity Diagram

4.10 Packages and Components – A Way to Organize Large and Complex Projects

4.11 Component and Deployment Diagram

4.12 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

5 Analysis and Design Methodologies

5.1 Introduction

5.2 Stages and Methodologies for Systems Development

5.2.1 Methodologies for Software Development

5.2.2 Systems Development Life Cycle (SDLC)

5.3 Structured Analysis and Design (SASD)

5.3.1 Conceptual Design – Functional Modelling and Data Modelling

5.3.2 Modular Design

5.3.3 Analysis and Design Techniques and Tools

5.3.4 Context Diagrams

5.3.5 Event List

5.3.6 Data Flow Diagrams

5.3.7 Data Dictionary

5.3.8 Multilevel DFDs

5.3.9 Entity Relationship Diagram

5.3.10 Process Specifications

5.3.11 Specifying Constraints

5.4 Case Study on Structured Analysis and Design

5.4.1 Example of Statement of Purpose

5.4.2 Context Diagram

5.4.3 Event List

5.4.4 Data Flow Diagrams

5.4.5 Data Dictionary

5.4.6 Entity Relationship Diagrams

5.4.7 Process Specifications – SSCS

5.4.8 Structured Analysis and Design – Advantages and Disadvantages

5.5 Object-oriented Software Analysis and Design (OOAD)

5.5.1 Different Models for Object Analysis

5.5.2 Identifying Classes

5.5.3 Identifying Attributes

5.5.4 Specifying Operations

5.5.5 Work Out Associations

5.6 OOAD: A Case Study

5.7 Design for Reuse

5.8 Comparison of SASD and OOAD Methodologies

5.9 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

6 C++ Fundamentals and Basic Programming

6.1 Introduction

6.2 History and Development of Object-oriented Languages like C++

6.3 Object-oriented Language Features

6.4 Welcome to C++ Language

6.4.1 Setting Path

6.4.2 C++ Program Structure

6.4.3 C++ Development Environment

6.5 Further Sample Programs of C++

6.5.1 Execution of a Program in a Loop

6.5.2 Arrays Implementation

6.5.3 Use of Structure to Implement Problem

6.5.4 Class Implementation

6.6 Console IO Operations

6.6.1 Console IO Functions – Commands getchar() and putchar()

6.6.2 Console IO Functions – Commands gets and puts

6.6.3 Unformatted Stream IO Functions – get(), put(), getline() and write()

6.7 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

7 C++ Programming Basics and Control Loops

7.1 Introduction

7.2 Declaration of Variables

7.3 Data Types

7.4 Declaration and Assignment Values to Variables

7.5 Expressions

7.6 Operators

7.6.1 IO Operators << and >>, iostream objects cin and cout

7.6.2 Unary Operators

7.6.3 Size of Operator

7.6.4 Arithmetic Operators

7.6.5 Relational and Logical Operators

7.6.6 Logical Operators

7.6.7 Conditional Expressions: Question Mark Operator

7.6.8 Comma Operator

7.6.9 Bitwise Operators

7.7 Precedence and Association of Operators

7.8 Control Loops

7.8.1 Conditional and Branching Statements

7.8.2 Switch and Case Statements

7.8.3 While Loop

7.8.4 Do-while Loop

7.8.5 For Loop

7.8.6 When to Use For or While or Do-while

7.9 Break and Continue

7.9.1 Break

7.9.2 Continue Statement

7.9.3 Goto Statements

7.9.4 Exit Function

7.10 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

8 Functions, Storage Class Preprocessor Directives, and Arrays and Strings

8.1 Introduction

8.2 Why Use Function Templates?

8.3 Call by Value

8.4 Call by Reference

8.5 Call by Constant Reference

8.6 Recursion

8.7 Inline Functions

8.8 Function Overloading

8.9 Default Arguments

8.10 Memory Management of C++

8.10.1 Types of Storage Classes

8.11 Header Files and Standard Libraries

8.12 C++ Preprocessor

8.12.1 Macro Expansion

8.12.2 Macro Definition with Arguments

8.12.3 File Inclusion

8.12.4 Conditional Inclusion

8.12.5 Conditional Compilation #ifdef and #ifndef Statements

8.12.6 #undef

8.12.7 #error Macros

8.13 Arrays

8.13.1 How are Arrays Stored in the Memory?

8.13.2 Array Initialization

8.13.3 Multi-dimensional Arrays

8.13.4 Character Array – String Handling in C++ Language

8.14 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

9 Pointers and References

9.1 Introduction

9.2 What, Why and How of Pointers

9.3 Pointers Declaration and Usage

9.4 Call by Value and Call by Reference (Pointers)

9.5 Dynamic Memory New and Delete Functions

9.5.1 Memory Leak

9.5.2 Dangling Pointer

9.5.3 Pointers and Arrays

9.5.4 Pointers and Two-dimensional Arrays

9.5.5 Array Declaration on Heap Memory

9.5.6 Pointer to Pointer

9.5.7 Dynamic Memory for a Two-dimensional Array

9.5.8 Pointers and Three-dimensional Arrays

9.5.9 Array of Pointers

9.5.10 Pointers to Void

9.5.11 Pointer to a Constant vs const Pointer

9.5.12 Pointers to Function

9.6 What, Why and How of References

9.6.1 Which is Better – Pointer or Reference?

9.7 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Solutions to Objective Questions

10 Classes

10.1 Introduction

10.2 Classes and Objects

10.2.1 How to Create an Object to a Class?

10.2.2 How to Access Member Data and Member Functions?

10.2.3 Constructors and Destructors

10.3 Friend Function

10.4 Class Within a Class: Container Class

10.5 Objects and Data Members on Heap Memory

10.6 This Pointer

10.7 Pointers vs Objects: Use of Constant Declarations

10.8 Passing of Objects by Reference and Pointers to a Function

10.9 Constant Pointers and Constant References

10.10 Static Member Data

10.11 Static Member Functions

10.12 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Solutions to Objective Questions

11 C++ Special Features: Errors and Exceptions and Operator Overloading

11.1 Introduction

11.2 Errors and Exceptions

11.3 Try and Catch Blocks

11.4 Exception Classes

11.5 Stack Data Structure

11.6 Operator Overloading

11.6.1 Overloading of + Operator and * Operator

11.6.2 Operator << Overloading

11.6.3 What We Can Overload and What We Cannot Overload

11.6.4 Overloading Assignment Operator =

11.7 Pre- and Post-increment Operator Overloading

11.8 Overloading Operators New and Delete

11.9 Conversion (Casting) Operators

11.10 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

12 Inheritance

12.1 Introduction

12.2 Inheritance Hierarchy

12.3 Types of Inheritance

12.4 Constructors and Destructors

12.5 Base Class Function Overriding

12.6 Base Class Function Hiding

12.7 Virtual Functions

12.8 Multiple Virtual Functions

12.9 Virtual Destructors: Why and How?

12.10 Hybrid Inheritance with Multiple Inheritances

12.11 Virtual Inheritance

12.12 Run-time Polymorphism and Dynamic Binding

12.13 Abstract Data Types (ADTs)

12.14 Pure Virtual Functions

12.15 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

13 IO Streaming

13.1 Introduction

13.2 IO Streaming

13.3 IO Library Files Classification

13.3.1 Formatted IO

13.3.2 Unformatted IO

13.3.3 IO Stream State

13.3.4 IO Stream Library – Header Files

13.4 IO Manipulators

13.5 Flags

13.6 File I/O

13.6.1 File Types

13.6.2 Stream Operating Modes

13.7 Binary File

13.8 Seekg()/Seekp() and Tellg() and Tellp() Functionality of C++

13.9 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

14 Generic Programming and Templates

14.1 Introduction

14.2 What is Generic Programming and Why Use Templates?

14.3 Template Classes

14.4 Function Templates and Passing of Arguments to a Function

14.5 Template Friends

14.5.1 Non-template Function

14.5.2 Template Friend Class or Function

14.5.3 Type-specific Friend Function in Class Templates

14.6 Templates and Static Member Functions and Member Data

14.7 Template Exceptions

14.8 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

15 Object-oriented Programming with Java

15.1 Introduction

15.2 Internet and the World Wide Web

15.3 C and C++ are Around – Then Why Java?

15.4 Java Story

15.5 Java Features

15.5.1 Portability or Platform Independent

15.5.2 Automatic Garbage Collection

15.5.3 Object-oriented Features

15.5.4 Easy to Learn and Excellent Documentation

15.5.5 Byte Code

15.5.6 Java Virtual Machine (JVM)

15.5.7 Comparison with C++

15.6 Developing First Java Application

15.6.1 Installing and Using Java Development Kit

15.6.2 Setting Path and Classpath

15.6.3 Java Program Structure

15.6.4 Java Documentation Comments

15.6.5 Java Development Environment

15.6.6 Our First Java Application

15.6.7 Application with Swing Components

15.6.8 Eclipse-integrated Development Environment

15.6.9 Command Line Arguments

15.7 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

16 Java Fundamentals and Control Loops

16.1 Introduction

16.2 Constants/Literal Constants

16.2.1 Integer Constants

16.2.2 Floating Point Constants/Real Constants

16.2.3 Character Constants

16.2.4 String Constants

16.2.5 Backlash Character Strings

16.2.6 Boolean Literals

16.2.7 Symbolic Constants

16.3 Variables and Assignment of Values to Variables

16.4 Data Types

16.4.1 Integer Data Types

16.4.2 Floating Point Data Types

16.4.3 Character Type

16.4.4 Boolean Data Type

16.5 Scope and Life Time of Variables

16.6 Arithmetic Operators

16.7 Type Conversion and Type Casting

16.7.1 Type Conversion

16.7.2 Type Cast

16.8 Unary Operators

16.8.1 Increment and Decrement Operators

16.8.2 Assignment Operator

16.8.3 Chained Assignment

16.8.4 Relational Operators

16.9 Logical Operators

16.10 Bit-wise Operators

16.11 Other Operators

16.11.1 Question Mark (?) Operator Conditional Expressions

16.11.2 Member Operator or Dot Operator

16.11.3 Instanceof Operator

16.11.4 New Operator

16.11.5 Operator Precedence and Associativity

16.12 Conditional and Branching Statements

16.12.1 If and If-Else Statements

16.12.2 Nested If Statements

16.12.3 If-Else-If Ladder

16.12.4 Switch and Case Statements

16.13 Control Loops

16.13.1 While Loop

16.13.2 Do-while Loop

16.13.3 For Loop

16.14 Break

16.15 Continue Statement

16.16 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

17 Simple IO and Arrays and Strings Vectors

17.1 Introduction

17.2 Input from Keyboard

17.2.1 System.in, System.out and System.err Commands

17.2.2 StringTokenizer to Receive Multiple Inputs in a Single Line

17.2.3 Obtaining Inputs Using Java's Scanner Class

17.2.4 Using Control Formats - System.out.printf()

17.2.5 Formatted Output with String Format

17.3 Arrays

17.3.1 Declaring and Creation of an Array

17.3.2 Initialization of Arrays

17.3.3 How Are Arrays Stored in the Memory?

17.3.4 Accessing and Modifying Array Elements

17.3.5 Passing Arrays as Arguments to Methods

17.3.6 Returning Arrays as Arguments to Methods

17.3.7 Multi-dimensional Arrays

17.3.8 Java.util. Arrays Class

17.4 String

17.4.1 Array of Strings

17.4.2 String Class Methods

17.4.3 StringBuffer Class

17.4.4 StringBuilder Class

17.5 Collection Framework

17.5.1 Vector Class

17.5.2 Vector Methods

17.6 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

18 Class Objects and Methods

18.1 Introduction

18.2 Classes and Objects

18.3 Declaring a Class and Creating of Instances of Class Variables

18.4 Constructors

18.4.1 Default Constructor

18.4.2 Parameterized Constructor and Overloading of Constructors

18.5 Specifying Private Access Specifiers and Use of Public Methods

18.5.1 Private Access Specifiers

18.5.2 Methods

18.5.3 Math Class of Java

18.5.4 Call by Value and Call by Reference

18.5.5 Passing and Returning of Objects To and From Methods

18.5.6 Method Overloading

18.6 Usage of this Keyword

18.7 Garbage Collection

18.8 Finalizer and Finalize() Methods

18.9 Final Variable

18.10 Access Control and Accessing Class Members

18.11 Static Members

18.12 Factory Methods

18.13 Nested Classes

18.14 Inner Classes

18.15 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

19 Inheritance: Packages: Interfaces

19.1 Introduction

19.2 Basic Concepts of Inheritance

19.3 Member Access Rules

19.4 Using Super Class

19.5 Methods Overriding

19.6 Multilevel Inheritance

19.7 Run-time Polymorphism

19.8 Abstract Classes

19.9 Using Final with Inheritance

19.9.1 Final Method

19.9.2 Final Classes

19.10 Object Class

19.11 Packages

19.11.1 Reusable Classes

19.12 Path and Classpath

19.13 Importing of Packages

19.14 Access Specifiers Revisited for Packages

19.15 Interfaces

19.15.1 What and Why of Interfaces

19.15.2 Defining and Implementing Interfaces

19.16 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

20 Errors and Exceptions in Java and Multithreaded Programming

20.1 Introduction

20.2 Errors and Exceptions

20.2.1 Errors

20.2.2 Exceptions

20.3 Try and Catch Blocks

20.4 Handling of Multiple Exceptions by Try and Catch Blocks

20.5 Using Finally Block

20.6 Throw Exceptions

20.7 Throws Exceptions

20.8 Re-throwing of an Exception

20.9 Defining Our Own Exception

20.9.1 Procedure for Throwing Our Own Exceptions

20.10 Concepts of Multithreading

20.10.1 Multithreaded Program

20.11 Process vs Threads

20.11.1 Process

20.11.2 Threads

20.12 How to Create and Run the Threads?

20.12.1 Which is Better: Extends Thread or Implements Runnable?

20.12.2 Use of isAlive() and join() Methods

20.13 Life Cycle of Thread

20.14 Thread Priorities

20.15 Synchronization

20.16 Inter-thread Communications

20.17 Deadlock in Multithreaded Programming

20.18 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

21 Java IO Files

21.1 Introduction

21.2 IO Streaming

21.3 Java IO Stream Classes

21.3.1 Classification of ByteStream Classes

21.3.2 Classification of CharacterStream Classes or Text Classes

21.3.3 DataInput and DataOutputStream FileInput and FileOutputStream

21.3.4 FileReader and FileWriter

21.4 IO Errors and Exceptions

21.5 FilterInputStream and FilterOutputStreams

21.6 Using BufferedInput and BufferedOutput Streams

21.7 Writing Primitive Data Types to File: DataInputStream/DataOutputStream

21.8 File Class

21.9 Random Access Files

21.10 Serialization of Objects and Object Streams

21.10.1 Serialization

21.10.2 De-serialization

21.11 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

22 Networking in Java

22.1 Introduction

22.2 Basics of Networking

22.2.1 TCP/IP

22.2.2 User Data Gram Protocol (UDP)

22.3 Internet Address

22.4 URL and URL Connection

22.4.1 URL Connection

22.5 TCP/IP Sockets

22.5.1 ServerSocket Class

22.5.2 Server and Socket for Communications: How to Set them to Work?

22.5.3 Client and Socket for Communications: How to Set them to Work?

22.6 Client Server Program

22.6.1 Client Server Two-way Communication Program

22.6.2 Multiple Clients and Server Programs Using Multithreads

22.6.3 Client Server Program for File Download from Server

22.7 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

23 Graphics Using Swing Components and Applets

23.1 Graphics Programming and Applets Introduction

23.2 Hierarchy of Graphics Software

23.3 Containers in Swing

23.3.1 JFrame Class

23.3.2 JPanel Class

23.4 Display Widgets in Swing

23.4.1 JLabel Class

23.4.2 JButton

23.4.3 JCheckBox

23.4.4 JComboBox

23.4.5 JMenu Class

23.5 Layout Managers

23.5.1 Border Layout

23.5.2 Grid Layout

23.5.3 Flow Layout

23.6 Event Types and Event Listeners

23.6.1 Action Event Listener

23.6.2 Item Event Listener

23.6.3 Keyboard Event Listener

23.6.4 Mouse Event Listener

23.7 Applets

23.7.1 Concepts of Applets

23.7.2 Life Cycle of an Applet

23.7.3 Creating an Applet - HelloWorld Applet

23.7.4 JApplets - Applets with Swing Components: Better Look and Feel

23.7.5 Applets vs. Stand-alone Applications

23.7.6 Passing Arguments to Applets

23.8 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

24 Collections and Software Development Using Java

24.1 Introduction

24.2 Collection Framework of Java

24.3 Collection Interface

24.4 Set Interface

24.5 Iterators

24.6 List Interface

24.7 Collection Algorithms

24.8 Map Interface

24.9 Collection View of Map

24.10 JDBC Database Connectivity

24.11 Access Database Records Using MS Access Database

24.12 Access Database Records Using MySql Open Source Database

24.13 Access Database Records Using Oracle Database

24.14 Prepared Statement and Callable Statements

24.14.1 PreparedStatement

24.14.2 Callable Statements

24.15 Servlets

24.15.1 Servlets API and javax.servlet Package

24.15.2 HttpServletRequest

24.15.3 HttpServletResponse

24.15.4 HttpServlet Class—Get Request with Data from Client

24.15.5 HTTP Post Requests

24.16 Java Beans

24.17 Summary

Exercise Questions

Objective Questions

Short-answer Questions

Long-answer Questions

Assignment Questions

Solutions to Objective Questions

Appendix A

Appendix B

Appendix C

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

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