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 the case of Java both the approaches are combined, thus it makes java a two-stage system. In the 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 Internet-based applications, this is possible because of their 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 a “Write Once, Run Everywhere” language.
Feature of Java:
Object-Oriented – Java is said to be a 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 supports the all the features of object-oriented programming language such as Abstraction, Encapsulation, Inheritance, Polymorphism, Dynamic binding, etc, which facilitates code modularization, reusability, testability, and performance. Except for the primitive data types, almost everything in java is treated as an object, even though primitive data types can also be converted into objects by using the wrapper class. In Java, there is no coding outside of class definitions, including the 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 a robust and secure programming language. java has built-in safeguards that enable the internet programmer to write reliable code. Java is strict about the compile-time and run-time checking of data. Java has advanced garbage collector type checking, exception handling, and memory management feature, that avoids overruns, leaked memory, illegal data access, and system crashing. Java has the secure execution of code across the network. To make Java secure many of the features of C and C++ were eliminated. Java does not use pointers that ensure the java programs cannot gain access to memory locations without proper authorization.
Distributed – In java we can create applications that can be distributed over the networks. Java applications can share the data and program. In java we can easily access and invoke remote objects over the internet, it enables collaborative working.RMI and EJB are used for creating distributed applications.
Simple and Familiar – Java is a 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 features of c and c++ are not part of the java programming language.Java support 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 the java program can perform multiple tasks 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 the java programs more interactive.
High Performance – Since java programs are compiled into portable intermediate code known as bytecodes, rather than native machine-level instructions, so it will never be as fast as a compiled language as C or C++. However, java can achieve the performance of native applications using a just-in-Time compiler. Java supports multi-threading which in turn enhances 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 support the native functions written in other programming languages such as c and c++. This facility allows the programmer to efficiently use and extend the functionality available in these languages. Linking of native methods is done dynamically in run time. Java has a very rich set of libraries which means no need to reinvent the wheel and what makes it extensible.