Tuesday, 7 August 2018

JAVA FEATURES



Compiled and 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. Bytecode 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.

Platform-Independent and Portable
Java is compiled to an intermediate form called Java Byte-Code or simply byte code. A Java
program never really executes immediately after compilation on the host machine. Rather,
this special program called the Java Interpreter or Java Virtual Machine reads the bytecode,
translates into the corresponding host machine instructions and then executes the machine
instruction. A java program can run on any computer system for which a JVM and some
library routines are installed. Because of Platform Independence Java programs can be
portable from a mini computer up to a super computer irrespective of H/W requirements and
OS Base.

Object-Oriented
Java is one of the Pure Object Oriented Programming Language where every construction of
the program should be written under the implementation of class which is the basic part of
OOPS.

Robust and Secure
Robustness is measured with the help of 2 concepts 1) Memory Management 2) Exception
Handling

In traditional applications, the programmer is responsible for both allocations and
de allocation of memory. In Java, Memory allocation is controlled by JVM where object
creation is done by the user de allocation is taken by Garbage Collector
In C,C++ error handling is done manually even before running the program. If any run-time
error comes the program is in inconsistent state which leads to memory leak. Java supports
pure exception handling which guards the program from abnormal situations.
Java is intended to work in networked and distributed environments by providing security.
Security becomes an important issue for a language that is used for programming on Internet.
Java Systems not only verify all memory access but also ensures 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.

Familiar, Simple and Small
By using Java different range of applications can be developed by keeping the common
structure which is understood by JVM. Java uses many constructs of C and C++ and
therefore, Java code looks like a C++ code.

Multithreaded and Interactive
Multithreaded means handling multiple tasks simultaneously. It is one of the important
features of Java that provides multi-tasking where 2 parts of a program can be runnable
concurrently by sharing the common block of resources. This feature greatly improves the
interactive performance of graphical applications.

High performance
Java performance is impressive for an interpreted language, mainly due to the use of
intermediate bytecode. Java architecture is also designed to reduce overheads during runtime.

Dynamic and Extensible
Java is capable of dynamically linking in new class libraries, methods and objects. In Java
classes that were unknown to a program when it was compiled can still be loaded into it at
runtime. Java programs support functions written in other languages such as C and C++.

Java Weaknesses:
Java is that it doesn’t directly support true decimal data.
Ex:
Double x = 5.02;
Double y = 0.01;
Double z = X + Y;
System.out.println(z);
Output:
5.029999999999999
But result is “5.03”

No comments: