Tuesday 3 July 2012

Java Environment


Java Environment :
Java emironment includes a large number of development tools and hundreds of classes and methods. The development tools are part of the system known as Java Development Kit (JDK) and the classes and methods are part of the Java Standard Library (JSL), also known as the Application Programming Interface (API).

Java Development 

The Java Development hit comes with a collection of tools that are used for developing and running Java programs. They include:
• appletviewer ( for viewing Java applets )
• avac ( Java compiler )
• java ( Java interpreter )
• javap ( .lava disassembler )
• javah ( for C header files )
javadoc ( for creating HTNIL documents )
• jdb ( Java debugger )
Table lists these tools and their descriptions.


The way these tools are applied to build and run application programs is illustrated in Fig. . To create a Java program, we need to create a source code file using a text editor. The source code is then compiled using the Java compiler javac and executed using the Java interpreter java. The Java debugger jdb is used to find errors, if any, in the source code. A compiled Java program can be converted into a source code with the help of Java disassembler javap. We learn more about these tools as we work through the book.

Application Programming Interface

The Java Standard Library (or API) includes hundreds of classes and methods grouped into several functional packages (see Appendix G). Most commonly used packages are:

• Language Support Package: A collection of classes and methods required for implementing basic features of Java.
• Utilities Package: A collection of classes to provide utility functions such as date and time functions.




• Input / Output : A Collection of classes required for input/output manipulation .

• Networking Package : A collection of classes for communicating with order computers
via Internet .

• AWT Package : The abstract window Tool Kit package contains classes that implements
platform-independent graphical user interface .

• Applet Package : The includes a set of classes that allows us to create java applets .

The use of these libray classes will become evident when we start developing java programs .







Wednesday 20 June 2012

Java Support Systems

Java Support:
It is clear from the discussion we had tip to now that the operation of Java and Java-enabled browsers on the Internet requires a variety of support systems. Table lists the systems necessary to support Java for delivering information on the Internet.

          Java Support Systems

Support System                      Deseriptilm
_________________________________________________________________

Internet Connection                           Local computer should be connected to the Internet.

Web Server                                     A program that accepts requests for information and sends the required                       
                                                         documents.


Wehlirowser                                   A program that provides access to WWW and runs Java applets.


lITNIL                                           
A language for creating hypertext for the Web.



APPLFT Tag                               For placing Java applets in FITML document.

Java Code                                   Java code is used for defining Java applets                                               

Bytecode                                   Compiled Java code that is referred loin the APPLET tag and transferred to             
                                                  the user computer..
_________________________________________________________________________________

Thursday 14 June 2012

Hardware And Software Requirement

Java - Hardware And Software Requirement :
Java is currently supported on Windows 95, Windows NT, Sun Solaris, Macintosh, and UNIX machines. Though, the programs and examples in this book were tested under Windows 95, the most popular operating system today, they can be implemented on any of the above systems.
The minimum hardware and software requirements for Windows 95 version of Java are as follows:

• IBM-compatible 486 system
• A hard drive
• Minimum of 8 MB memory
• A CD-ROM drive
• Windows 95 software
• A Microsoft-compatible mouse
• A Windows-compatible sound card, if necessary

Tuesday 5 June 2012

HotJava

Hot Java:

HotJava is the Web browser from Sun Microsystems that enables the display of interactive content on the Web, using the Java language. HotJava is written entirely in Java and demonstrates the capabilities of the Java programming language.
When the Java language was first developed and ported to the Internet, no browsers were available that could run Java applets. Although we can view a Web page that includes Java applets with a regular browser, we will not gain any of Java's benefits. HotJava is currently available for the SPARC/Solaris platform as well as Windows 95 and Windows NT. So far as being a Web browser goes, it is nothing special and does not offer anything special that most other Web browsers don't offer. Its biggest draw is that it was the first Web browser to provide support for the .Java language, thus making the Web more dynamic and interactive.

Netscape Navigator

Netscape N:ivigator, from Netscape Communications Corporation, is a general-purpose browser that can run Java applets. With versions available for Windows 95, NT, Solaris and Apple Macintosh, Netscape Navigator is one of the most widely used browsers today.
Netseape Navigator has many useful features such as visual display about downloading process and indication of the number bytes downloaded. It also supports JavaScript, a scripting language used in HTML documents.

Internet Explorer

Internet Explorer is another popular browser developed by Microsoft for Windows 95 and NT Workstations. Both the Navigator and Explorer use tool bars, icons, menus and dialog boxes for easy navigation. Explorer uses a just-in-time (JIT) compiler which greatly increases the speed of execution.

Saturday 26 May 2012

Web Browsers

Web Browser: 
As pointed out earlier, the Internet is a vast sea of information represented in many formats and stored on many computers. A large portion of the Internet is organized as the World Wide Web which uses hypertext. Web browsers are used to navigate through the information found on the net. They allow us to retrieve the information spread across the Internet and display it using the hypertext markup language (I-ITML). Examples of Web browsers, among others, include:


• Hot Java
• Netscape Navigator
• Internet Explorer


Thursday 17 May 2012

Java And World Wide Web

Java And Web:

World Wide Web (\\*WW) is an open-ended information retrieval system designed to be used in the Internet's distributed environment. This system contains what are known as Web pages that provide both information and controls. Unlike a menu-driven system where we are guided



through a particular direction using a decision tree structure, the Web system is open-ended and we can navigate to a new document in any direction as shown in Fig. . This is made possible with the help of a language called Hypertext Markup Language (HTML). Web pages contain HTML tags that enable us to find, retrieve, manipulate and display documents worIchvide.
Java was meant to be used in distributed environments such as Internet. Since, both the Web and Java share the same philosophy, Java could be easily incorporated into the Web system. Before Java, the World Wide Web was limited to the display of still images and texts. However, the incorporation ofJava into Web pages has made it capable of supporting animation. graphics, games, and a wide range of special effects. With the support of Java, the Web has become more interactive and dynamic. On the other hand, with the support of Web, we can run a Java program on someone else's computer across the Internet.




Java communicates with a Web page through a special tag called <APPLET>. Figure  illustrates this process. The figure shows the following communication steps:
1. The user sends a request for an HTML document to the remote computer's Web server. The Web server is a program that accepts a request, processes the request, and sends the required document.
2. The HTNIL document is returned to the user's browser. The document contains the APPLET tag, which identifies the applet.
3. The corresponding applet bytecode is transferred to the user's computer. This bytecode had been previously created by the Java compiler using the Java source code file for that applet.
4. The Java-enabled browser on the user's computer interprets the bytecodes and provides output.
5. The user may have further interaction with the applet but with no further downloading from the provider's Web server. This is because the bytecode contains all the information necessary to interpret the applet.




Friday 11 May 2012

Java And Internet


Java And Internet:
Java is strongly associated with the Internet because of the fact that the first application program written in Java was HotJava. a Web browser to run applets on Internet. Internet users can use Jas -a to create applet programs and run them locally using a "Jas -a-enabled browser'. such as HotJava. They can also use a Java-enabled browser to download an applet located on a computer any, there in the Internet and run it on his local computer . In fact, Java applets have made the Internet a true extension of the storage system of the local computer.
Internet users can also set up their Web sites containing Java applets that could be used by other remote users of Internet. The ability of Java applets to hitch a ride on the Information Superhighway has made Java a unique programming language for the Internet. In fact, due to this, Java is popularly known as Internet language.

Sunday 6 May 2012

Java Differ From C And C++


Although java was modeled after C and C++ languages, it differ from C and C++ in many ways, java does not incorporate a number of features available in C and C++. For the benefit of C and C+ + programmers, we point out here a few major differences between C/C+ + and Java languages.

Java and C

Java is a lot like C but the major difference between Java and C is that Java is an object-oriented language and has mechanism to define classes and objects. In an effort to builds simple and safe language. the Java team did not include some of the C features in Java.
Java does not include the C unique statement keywords goto, sizeof, and typedef.
Java does not contain the data types struct, union and enum.
Java does not define the type modifiers keywords auto, extern, register, signed, and unsigned.
Java does not support an explicit pointer type.
Java does not have a preprocessor and therefore we cannot use # define, # include, and # ifdef statements.
Java does not support any mechanism for defining variable arguments to functions.
Java requires that the functions with no arguments must be declared with empty parenthesis and not with the void keyword as done in C.
Java adds new operators such as instanceof and > > >.
Java adds labelled break and continue statements.
Java adds many features required for object-oriented programming.

Java and C+ +

Java is a true object-oriented language while C+ + is basically C with object-oriented extension. That is what exactly the increment operator ++ indicates. C++ has maintained backward compatibility with C. It is therefore possible to write an old style C program and run it successfully under C+ +. Java appears to be similar to C+ + when we consider only the "extension" part of C+ +. However, some object-oriented features of C++ make the C++ code extremely difficult to follow and maintain.
Listed below are some major C+ + features that were intentionally omitted from Java or significantly modified.
Java does not support operator overloading.
Java does not have template classes as in C+ +.
Java does not support multiple inheritance of classes. This is accomplished using a new feature called -interface".
Java does not support global variables. Every variable and method is declared within a class and forms part of that class.
Java does not use pointers.
Java has replaced the destructor function with a finalize( ) function.
There are no header files in Java.

Java also adds some new features. While C+ + is a superset of C. Java is neither a superset nor a subset of C or C++. Java may be considered as a first cousin of C++ and a second cousin of C as illustrated in Fig.. A more detailed discussion on the differences between C+ + and Java is available in Appendix C.




Saturday 28 April 2012

Java Features

Java Feature : 

The inventors of Java wanted to design a language which could offer solutions to some of the problems encountered in modern programming. They wanted the language to be not only reliable, portable and distributed but also simple, compact and interactive. Sun Microsystems officially describes Java with the following attributes:
·   Compiled and Interpreted
·   Platform-Independent and Portable
·   Object-Oriented
·   Robust and Secure
·   Distributed
·   Familiar, Simple and Small
·   Multithreaded and Interactive
·   High Performance
·   Dynamic and Extensible

Although the above appears to be a list of buzzwords, they aptly describe the full potential of the language. These features have made Java the first application language of the World Wide Web. Java will also become the premier language for general purpose stand-alone applications.
Compiled and Interpreted
Usually a computer language is either compiled or interpreted. Java combines both these approaches thus making Java a two-stage system. First, Java compiler translates source code into what is known as bytecode instructions. Bytecodes are not machine instructions and therefore, in the second stage, Java interpreter generates machine code that can be directly executed by the machine that is running the Java program. We can thus say that Java is both a compiled and an interpreted language.


Platform-Independent and Portable

The most significant contribution of Java over other languages is its portability. Jaya programs can be easily moved from one computer system to another, anywhere and anytime. Changes and upgrades in operating systems, processors and system resources will not force any changes in Java programs. This is the reason why Java has become a popular language for programming on Internet which interconnects different kinds of systems worldwide. We can download a Java applet from a remote computer onto our local system via Internet and execute it locally. This makes the Internet an extension of the user's basic system providing practically unlimited number of accessible applets and applications.
Java ensures portability in two ways. First. Java compiler generates bytecode instructions that can be implemented on any machine. Secondly, the size of the primitive data types are machine-independent.

Object-Oriented
Java is a true object-oriented language. Almost everything in Java is an object. All program code and data reside within objects and classes. Java comes with an extensive set of classes, arranged in packages, that we can use in our programs by inheritance. The object model in Java is simple and easy to extend..
Robust and Secure

Java is a robust language. It provides many safeguards to ensure reliable code. It has strict compile time and run time checking for data types. It is designed as a garbage-collected language relieving the programmers virtually all memory management problems. Java also incorporates the concept of exception handling which captures series errors and eliminates any risk of crashing the system.
Security becomes an important issue for a language that is used for programming on Internet. Threat of viruses and abuse of resources is everywhere. Java systems not only verify all memory access but also ensure that no viruses are communicated with an applet. The absence of pointers in Java ensures that programs cannot gain access to memory locations without proper authorization.

Distributed
Java is designed as a distributed language for creating applications on networks. It has the ability to share both data and programs. Java applications can open and access remote objects on Internet as easily as they can do in a local system. This enables multiple programmers at multiple remote locations to collaborate and work together on a single project.
Simple, Small and Familiar

Java is a small and simple language. Many features of C and C++ that are either redundant or souree_s of unreliable code are not part of Java. For example, Java does not use pointers, preprocessor header tiles, goto statement and many others. It also eliminates operator overloading and multiple inheritance. For more detailed comparison of Java with C and C+ + .

Familiarity is another striking feature of Java. To make the language look familiar to the existing programmers, it was modelled on C and C+ + languages. Java uses many constructs of C and C++ and therefore, Java code "looks like a C+ +" code. In fact, Java is a simplified version of C+ +.

Multithreaded and Interactive

Multithreaded means handling multiple tasks simultaneously. Java supports multithreaded programs. This means that we need not wait for the application to finish one task before beginning another. For example. we can listen to an audio clip while scrolling a page and at the same time download an applet from a distant computer. This feature greatly improves the interactive performance of graphical applications.
The Java runtime comes with tools that support multiprocess synchronization and construct smoothly running interactive systems.

High Performance

Java performance is impressive for an interpreted language. mainly due to the use of intermediate byteeode. According to Sun, Java speed is comparable to the native C/C++. Java architecture is also designed to reduce overheads during runtime. Further, the incorporation of multithreading enhances the overall execution speed of Java programs.

Dynamic and Extensible

Java is a dynamic language. Java is capable of dynamically finking in new- class libraries. methods. and objects. Java can also determine the type of class through a query. making it possible to either dynamically link or abort the program. depending on the response.
Java programs support functions written in other languages such as C and C++. These functions are known as notice methods. This facility enables the programmers to use the efficient functions available in these languages. Native methods are linked dynamically at runtime.



Saturday 21 April 2012

OOP Application

OOP :

OOP is one of the programming buzzwords today. There appears to be a great deal of excitement and interest among software engineers in using 00P. Applications of 00P are beginning to gain importance in many areas. The most popular application of object-oriented programming, up to now, has been in the area of user interface design such as windows. There are hundreds of windowing systems developed using 00P techniques.
Real-business systems are often much more complex and ,ontain many more objects with complicated attributes and methods. 00P is useful in this type of applications because it can simplify a complex problem. The promising areas for application of 00P includes:
·      Real-time systems
·      Simulation and modelling
·      Object-oriented databases
·      Hypertext, hypermedia and expertext
·      Al and expert systems
·      Neural networks and parallel programming
·      Decision support and office automation systems
·      CIM/CAD/CAD system
It is believed that the richness of OOP environment will enable the software industry to Improve not only the quality of software systems but also its productivity. Object-oriented
Technology is certainly going to change the way software engineers will think, analyze design and implement system in the future .

Sunday 15 April 2012

Benefits Of OOP

OOP :

OOP offers several benefits to both the program designer and the user. Object-orientation contributes to the solution of many problems associated with the development and quality of software products. The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost. The principal advantages are:
Through inheritance, we can eliminate redundant code and extend the use of existing classes.
We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity.
The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.
It is possible to have multiple objects to coexist without any interference.
It is possible to map objects in the problem domain to those objects in the program.
It is easy to partition the work in a project based on objects.
The data-centered design approach enables us to capture more details of a model in an implementable form.
Object-oriented systems can be easily upgraded from small to large systems.
Message passing techniques for communication between objects make the interface descriptions with external systems much simpler.
Software complexity can be easily managed.
While it is possible to incorporate all these features in an object-oriented system, their importance depends on the type of the project and the preference of the programmer. There are a number of issues that need to be tackled to reap some of the benefits stated above. For instance, class libraries must be available for reuse. The technology is still developing and current products may be superseded quickly. Strict controls and protocols need to be developed if reuse is not to be compromised.
A software that is easy to use is hard to build. It is hoped that the object-oriented programming languages like C+ + and Java would help manage this problem.



Wednesday 11 April 2012

Message Communication

Java - Message Communication :

An object-oriented program consists of a set of objects that communicate with each other. The process of programming in an object-oriented language, therefore, involves the following basic steps:
1. Creating classes that define objects and their behaviour.
2. Creating objects from class definitions.
3. Establishing communication among objects.
Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another as shown in Fig. . The concept of message passing makes it easier to talk about building systems that directly model or simulate their real-world counterparts.



A message for an object is a request for execution of a procedure. and therefore will invoke a method (procedure) in the receiving object that generates the desired result, as shown in Fig.



Message passing involves specifying the name of the object. the name of the method (message) and the information to be sent. For example. consider the statement
Employee.salary(name);


Here. Employee is the object. salary is the message and name is the parameter that contains information.




Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it is alive. 



Friday 6 April 2012

Dynamic Binding

Java - Dynamic Binding :

Binding refers to the linking of a procedure call to the code to be executed in response to the
call. Dynamic binding means that the code associated with a given procedure call is not Know until the time of the call at runtime. It is associated with polymorphism and inheritance. A procedure call associated with a polymorphic reference depends on the dynamic type of the reference.


Consider the procedure "draw" in Fig. By inheritance, every Object will have this procedure. Its algorithm is, however, unique to each object and so the draw procedure will be redefined in each class that defines the object. At run-time, the code matching the object under current reference will he called.


Thursday 29 March 2012

Polymorphism

Polymorphism :

Polymorphism is another important OOP concept. Polymorphism means the ability to take more than one form. For example, an operation may exhibit different behavior in different instances. The behavior depends upon the types of data used in the operation. For example consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by Concatenation. Figure illustrates that a single function name can be used to handle different number and different types of arguments. This is something similar to a particular word having several different meanings depending on the context.


Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface. This means that a general class of operation may be accessed in the same manner even though specific actions associated with each operation may differ. Polymorphism is extensively used in implementing inheritance.

Thursday 22 March 2012

Inheritance

Inheritance:

Inheritance is the process by which objects of one class acquire the properties of objects of another class. Inheritance supports the concept of hierarchical classification. For example, the bird robin is a part of the class flying bird, which is again a part of the class bird. As illustrated in Fig. 1.4, the principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived.


Property Inheritance 

 In 00P, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes. Thus the real appeal and power of the inheritance mechanism is that it allows the Programmer to reuse a class that is almost, but not exactly, what he wants, and to tailor the class in such a way that it does not in introduce any undesirable side effects into the rest of the classes.In Java, the derived class is known as 'subclass'. Note that each subclass defines only those features that are unique to it. without the use of inheritance. each class Would have to explicitly include all of its features.

Thursday 15 March 2012

Data Abstraction and Encapsulation

Data Abstraction:

The wrapping up of data and methods into a single unit (called class) is known as encapsulation. Data encapsulation is the most striking feature of a class. The data is not accessible to_the outside world and only those methods, which are wrapped in the class, can access it. These methods provide the interface between the object's data and the program. This insulation of the data from direct access by the program is called data hiding. Encapsulation makes it possible tor objects to be treated like 'black boxes', each performing a specific task without any concern for internal implementation

 



Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and methods that operate on these attributes. They encapsulate all the essential properties of the objects that are to be created.

Tuesday 13 March 2012

Object Oriented Programming Concepts

Object Oriented Programming Basics

As mentioned earlier, object-oriented is a term, which is interpreted differently by different people. It is therefore necessary to understand some of the concepts used extensively in object-oriented programming. We shall now discuss the general concepts of OOP which form the heart I if .lava language.

Objects and Classes

Objects are the basic runtime entities in an object-oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program may handle. They may also represent user-defined data types such as vectors and lists. Any programming problem is analyzed in terms of objects and the nature of communication between them. Program objects should be chosen such that they match closely with the real-world objects. As pointed out earlier, an object takes up space in the memory and has an associated address like a record in Pascal, or a structure in C.

When a program is executed, the objects interact by sending messages to one another. For example, 'customer' and 'account are two objects in a banking program, then the customer object may send a message to the account object requesting for the balance. Each object contains data and code to manipulate the data. Objects can interact without having to know the details of each other's data or code. It is sufficient to know the type of message accepted and the type of response returned by the objects. Although different authors represent them differently, Fig. 1.2 shows ti notation that is Popularly used to represent an object in object oriented analysis and design.

We just mentioned that objects contain data and code to manipulate that data. The entire set of data and code of an object can be made a user-defined data type using the concept of a class. A c!ass may be thought of as a 'data type' and an object as a 'variable' of that data type. Once a class has been defined, we can create any number of objects belonging to that class. Each object is associated Wit lit he data of type class with which they are created. A class is thus a collection of objects of similar type. For example, mango, apple and orange are members of the class fruit.


Classes are user-defined data types and behave like the built-in types of a programming language. For example, the syntax used to create an object is no different than the syntax used to create an integer object in C. If fruit has been defined as a class, then the statement
Fruit mango •
will create an object mango belonging to the class fruit

Sunday 11 March 2012

OBJECT ORIENTED PARADIGM

Object Oriented:

The major objective of object-oriented approach is to eliminate some of the flaws encountered in the procedural approach. OOP treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it and protects it from unintentional modification by other functions. 00P allows us to decompose a problem into a number of entities called Objects and then build data and functions (known as methods in Java) around these entities. The combination of data and methods make up an object 



The data of an object can be accessed only by the methods associated with that object,
However, methods of one object can access the methods of other objects. Some of the features of object-oriented paradigm are:

• Emphasis is on data rather than procedure.
• Programs are divided into what are known as Objects.
• Data structures are designed such that they characterize the objects.
• Methods that operate on the data of an object are tied together in the data structure.
• Data is hidden and cannot be accessed by external functions.
• Objects may communicate with each other through methods.
• New data and methods can be easily added whenever necessary.

• Follows botrom-up approach in Program design.

Object-Oriented paradigm is the most recent concept among programming paradigms and
still it means differnt things to diffrent people. It's thefore important to have
a working definition of Object-Oriented programming before we proceed further.

Our definition of Object-Oriented paradigm is:
Object-oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. This means that an object is considered to be a partitioned area of computer memory that store data and set of operations that can access that data. Since the memory partition are Independent, the object can be used in a variety of  different programs without modifications.

Saturday 10 March 2012

Fundamentals of Object- Oriented Programming

INTRODUCTION

One characteristic that is constant in the software industry today is the "change". Change is one of the most critical aspects of software development and management. New tools and new approaches are announced almost every day. The impact of these developments is often very extensive and raises a number of issues that must be addressed by the software engineers. Most important among them are maintainability, reusability, portability, security, integrity, and user friendliness of software products.

To build today's complex software it is just not enough to put together a sequence of programming statements and sets of procedures and modules. We need to use sound construction techniques and program structures that are easy to comprehend, implement and modify in a wide variety of situations.

Since the invention of the computer, many programming approaches have been tried. These include techniques such as modular programming, top-down programming, bottom-up programming and structured programming. The primary motivation in each case has been the concern to handle the increasing complexity of programs that are reliable and maintainable. These techniques became popular among programmers over the last two decades.

With the advent of languages such as C, structured programming became very popular and was the paradigm of the 1980s. Structured programming proved to be a powerful tool that enabled programmers to write moderately complex programs fairly easily. However, as the programs grew larger, even the structured approach failed to show the desired results in terms of bug-free, easy-to-maintain, and reusable programs.

Object-Oriented Programming (OOP) is an approach to program organization and development, which attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several new concepts. It is a new way of organizing and developing programs and has nothing to do with any particular language. However, not all languages are suitable to implement the OOP concepts easily. Languages that support OOP features include Smalltalk, Objective C, C + + , Ada and Object Pascal. C+ +, an extension of C language, is the most popular 00P language today C++ is basically a procedural language with object-oriented extension. The latest one added to this list is Java, a pure object-oriented language.