In this tutorial you will learn about the Java Features and its application with practical example.
Why Java? – Features of java
Compiled and Interpreted – Usually a computer programming language can be either compiled or interpreted, but in case of Java both of the approach is combined, thus it makes java a two stage system. In first stage source code is transferred into the bytecode format by the java compiler and it is platform neutral code. In the second stage Java Interpreter generates the machine code that can be executed directly by the machine running the java program.
Platform Independent and Portable – Portability is the key feature of java, which made the java programming language more popular for programming the Internet based applications, this is possible because of there compiled and interpreted nature. As the java programs are compiled into a platform independent format called bytecode, instead of native machine code (as in C and C++). Which is then interpreted (compiled into native-code) at runtime. Java is “Write Once, Run Everywhere” language.
Object Oriented – Java is said to be true object oriented programming language, which means that you focus on the data in your application and methods that manipulate that data, rather than thinking of procedures. Java support the all the features of object oriented programming language such as Abstraction, Encapsulation, Inheritance, Polymorphism and Dynamic binding etc, which facilitates code modularization, reusability, testability, and performance. Except the primitive data types, almost everything in java is treated as object, even though primitive data types can also be converted into object by using the wrapper class.In Java there is no coding outside of class definitions, including main() function. Java comes with an extensive class library available in the core language packages that can be extended further.
Robust and Secure – Java is said to be robust and secure programming language. java has the built in safeguards that enables the internet programmer to write reliable code. Java is strict about the compile time and run time checking of data. Java has the advance garbage collector type checking, exception handling, and memory management feature, that avoids the overruns, leaked memory, illegal data access and system crashing. Java has the secure execution of code across network. To make Java secure many of the features of C and C++ were eliminated. Java does not use pointers that ensures the the java programs cannot gain access to memory locations without proper authorization.
Distributed – In java we can create the the applications that can be distributed over the networks. Java applications can share the data and program. In java we can easily access and invoke the remote objects over the internet, it enables the collaborative working.RMI and EJB are used for creating distributed applications.
Simple and Familiar – Java is small and simple programming language. Java uses many constructs of c and c++ which makes it familiar to the existing programmers. Many of the redundant and unreliable feature of c and c++ are not part of the java programming language.Java supports automatic memory management, exception handling, single inheritance, standardized documentation, and a very rich set of libraries (no need to reinvent the wheel).
Multithreaded and Interactive -One of the powerful aspects of the Java language is that it allows multiple threads of execution to run concurrently within the same program, which means java program can perform multiple task simultaneously. A single Java program can have many different threads executing independently and continuously. Multiple Java applets can run on the browser at the same time sharing the CPU time, which makes java program more interactive.
High Performance – Since java programs are complied into portable intermediate code known as bytecodes, rather than to native machine level instructions, so it will never be as fast as a compiled language as C or C++. However, java can achieve performance of native applications using just-in-Time compiler. Java supports multi-threading which in turn enhance the overall execution speed of java applications.
Dynamic and Extensible – Java programs are said to be dynamic in nature. In java linking of class libraries, methods, objects and any other resource allocation is done dynamically when needed. Java programs supports the native functions written in other programming language such as c and c++. This facility allows the programmer to efficiently use and extend the function available in these language. Linking of native methods is done dynamically in run time. Java has very rich set of libraries which means no need to reinvent the wheel and what makes it extensible.