THE dealing with multiple frameworks .Earlier languages (like

THE JAVA LANGUAGE ENVIRONMENT

(A WHITE PAPER)

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

 

CHAPTER 1: INTRODUCTION TO JAVA

Now we have systems which can work with multiple O.S. dealing with multiple frameworks .Earlier languages (like C or C++) had dependencies with reference to different architectural properties or different software in the system .For example: In C language, different memory size is allocated to integer (int) data type for 32 bit and 64 bit systems.

Needs were required to build application which can work on heterogeneous environment anytime anywhere. Internet connecting people worldwide, making data available for all to use also led to urge of developing improved versatile applications which can work without any complications on each and every system. In order to solve the older problems OOPS brought more other complications. So we needed to deal with this all which brought the Java programming language into picture by Sun Microsystems.

It would include:

Programming language which is simpler includes more speed due to interpretation part (saving time of compilation, linking, loader, testing, crashing of program and error resolving).

Transfer of programs in systems with different O.S is easier now and applications can run without any dependency (increasing portability).With efficient memory management and automatic garbage collection technique will add robust feature to our applications.

Multithreading featured more enhancements to GUI based applications as they can now have greater performance rate. Applications are adaptable to changes now and any set of working segments can be loaded into our system through network.

As Internet world is taken as a place full of data as well as insecurities due to its open channel but efficient Java run time system has predefined features which adds secure environment to it.

Thus these features are now available with Java Programming Language.

Also the very first attention gaining application made using Java is HotJava which is WWW browser where java build fragments can be downloaded and run dynamically.

With involvement of least resources, java can provide secure applications which are platform-independent. Java found its roots with a starting of research work. Main idea with the beginning of development of this language was providing a light weight, more secure, can work distributed and real time systems. Initial steps started with improvements in C++ but it involved many problems which could be best treated by developing a new language itself. It involved features of Eiffel, Smalltalk, Objective and Cedar/Mesa which overall resulted in secured, platform independent, network compatible environment. Java was developed with a picture in mind to make it hardware independent, easily transferrable and runtime adaptability.

As it included some features of C++ too so did not come as a wholly new thing difficult to understand and developers found it familiar, simpler and easier to learn. So this simple object oriented programming language did not demand large-scale training requirements.

Architectural neutral and portable feature comes in java by the Byte code generated by Java compiler. This code makes java WORA (Write once Run anywhere).The byte code generated is same for every system irrespective of differences in hardware and software resources. There is no data type dependency in java from system to system. This all is done by Java Virtual Machine (JVM) based on POSIX interface.

High performance is maintained by automatic garbage collector that runs with less priority as a background process, thus making more space available for major processes leading to higher performance.

Java is robust and secure as it has two levels for executing a program-first compilation and then interpretation. There is no use of pointer here as was in C++ which reduces the risk of dangling pointers and program crash.  Java applications are secure which restricts entry of illegal intrusions.

Java is interpreted, threaded and dynamic. On compilation of Java programs, Byte code is generated which java interpreter can further interpret, with respect to, particular O.S. of the system. JVM has built in feature to provide interpreters for different operating system and pre-interpreted code (Byte code) is same for all machines so this makes java platform –independent.Network applied browsers like WWW , HotJava has to perform multiple tasks interaction with the end-user which becomes possible with multi-threading feature of Java. Its language library supplies thread class and run-time module gives condition lock built-ins. Static compilation, dynamic run-time environment and classes linking are only made when needed. There is on-line services feature in java which means that any library class can be imported anytime needed.

Java Base System: Java has many libraries to perform various functions such as java.lang which is required wherever we have need of creating class-object structure. Also exceptions, wrapper classes etc are added onto it. Java.io works as standard I/O Library.java.net provides features for sockets, telnet; interfaces etc. java.util contains utility classes. Dictionary, Hash Table, Stack, Date, Time and encoder-decoder methods are found here. java.awt – Abstract Windowing Toolkit helps in increasing portability feature of java programs.

The most important feature which makes Java different from other languages is its platform-independent code with its run-time environment provided by JVM which makes java code portable and has same functionality on every system.

CHAPTER-2 JAVA-SIMPLE AND FAMILIAR

Java looked familiar to earlier languages like C and C++ because it includes many features of these languages and looks similar to them and it’s simple because it has removed many complications from the previous languages. The simplest program in java can be as follows:

HelloWorld program which prints HelloWorld

                class HelloWorld{

                                public static void main(String args){

                                System.out.println(“Hello World!”);

                                }

                                }

Here HelloWorld is a class name, class keyword is used for declaring a class .main () method is used for start of execution of program and there string HelloWorld is printed by calling println() method of out object which is class variable of System class.

Primitive Data Types in Java: Java has three divisions for primitive data types-numeric, Boolean and arrays. The difference here from earlier languages include that everything in java is treated as object .Even encapsulation of primitive data types are also possible within library supplied objects.

Numeric Data type: byte (8 bit), short (16 bit), int (32 bit), long (64 bit).char in C or C++ was the smallest size data type but here it is replaced by byte. No unsigned type in integer data types. Real numeric data types include float (32 bit), double (64 bit) .Default real numeric data type is taken as double if nothing is specified.

Character Data type: char data type here is of 16 bit following Unicode-character system-which includes unsigned characters ranging from 0 to 65535.

                E.g. char ami = ‘A’ will return Unicode value of A.

Unicode supports every language and thus helps in making java internationalized and localized stretching understandability of java code worldwide.

Boolean Data type: Boolean type includes either true or false value only. This data type cannot be converted to other data types.

Arithmetic and Relational Operators: All earlier operators had same functionality in java too .Only thing added is >>> (logical right shift) as java does not include unsigned data types.

Arrays: They are first-class language object. It is a real-object with dynamic entries possibility. Arrays of different data types and Multi-dimensional arrays can also be made.

For e.g. Sum arr; where Sum is a class and arr is class type array of Sum class and by writing Sun arr = new Sum10; 10 memory locations will be created where 10 class type objects will be referenced. Java removes the bug of C and C++ where it allowed entries in array even out of order of its size. IndexOutOfBound exception is generated if any index outside the length is referred. To find length of array, we can use arrayname.length() function. Now there is no concept of pointer to array as it was in C. No “delayed-crash” syndrome occurs now.

Strings: In C we considered string as an array of characters with null character at the end to mark the limit of the string. There is no such case in java. They are a part of java reference object. String objects are of two type: String and StringBuffer .String is immutable while StringBuffer is mutable string object. Strings are given inside double quotes (“”).For e.g. String sen = “Life”; here string object is created. With the help of ‘+’ operator java performs the job of concatenation.

e.g. System.out.println(“Sum of two numbers”+a+” “+b+”is “+c);

With length () function we can get the number of characters in the string.

Multi-level Break: No goto statement is used here. break and continue are jump statements here which can be used for multi level break. Additionally labels can be specified to block and with the help of continue label name control can switch to that block. For example:

outer: for(int i =0;i

*************************************************************************************