Features Of Java
Features Of Java
[vc_row][vc_column][vc_column_text]
Features Of Java
There is given many features of Java. They are also known as Java buzzwords.
Features of Java Programming Language are:
Simple:
Java borrows most of it’s syntax from C/C++ languages.
Moreover it has inherited best points from these languages and dropped others.
Like it has removed pointers, multiple inheritance etc as developers of java language found these features to be security threat and confusing.
Thus if we have basic understanding of C/C++ languages it is very easy to learn Java.
Secure:
Java does not use pointers explicitly.
Moreover all the programs in java are run under an area known as the Sand box.
This sandbox uses a bytecode verification process to ensure that code loaded does not violate Java security constraints.
Platform Independent:
Java programs can execute in any environment for which there is a Java run-time system.(JVM)
Java programs can be run on any platform (Linux, Windows, Mac)
Java programs can be transferred over world wide web (e.g applets)
Thus any such platform for which a JVM is available can be used to execute a Java application irrespective of where it has been compiled.
This is how java makes itself “Platform Independent” and it also truly justifies java’s slogan of “WORA”(Write Once Run Anywhere)
Object-oriented:
Java supports all important concepts of OOPs, like
Encapsulation
Inheritance
Polymorphism
Abstraction
Robust:
Java has very strict rules which every programmer must compulsorily follow and if these rules are violated then JVM kills/terminates the code by generating “Exception”
To understand java’s robustness , guess the output of the following C/C++ code:
int arr[5]; int i; for(i=0;i<=9;i++) { arr[i]=i+1; //Unpredictable, after i is 5 }
The previous code might show uncertain behaviour in C/C++ i.e. if memory is available after arr[4] , then the code will run , otherwise it will generate error at runtime.
On the other hand if in java this code is executed, the JVM will kill the application as soon as it finds the statement arr[5]=. . .
Reason is that in java we are not allowed to access any array beyond it’s upper/lower index
Multithreaded:
Multithreading means concurrent execution.
In simple terms it means that we can execute more than one part of the same program parallely/simultaneously.
Q- Can we say that if we are surfing the internet using our browser and at the same time we are listening to song in winamp, the it is multithreading ?
A- It is mutlitasking not multithreading
To understand this feature consider the code given below:
main() { clrscr(); factorial(5); prime(8); evenodd(4); } . . .
In the above sample code all 4 functions clrscr(),factorial(),prime() and evenodd() are independent of each other but still they will run sequentially i.e. one after the other.
This can be improved in java by using multithreading feature so that each one of these functions can run together.
Benefits: Reduced execution time , full utilization of CPU
Some practical examples where multithreading is used are:
We can open multiple tabs in the same browser window
When we use a media player to listen to a song , then there are multiple activities which take place parallely like moving of a slider, elapsed time being shown, volume adjustment , ability to add or remove songs from the playlist , playing of the song etc
Distributed:
Distributed programming a program uses more than one computer.
That is, different parts of the same program run on different computers and communicate over a network.
In Java, this is made possible by a technique called RMI(Remote Method Invocation)
RMI allows a method that is running on one computer to call a method in an object that is on another computer.
Benefits: Programmers working on same project may be required to be physically present at the same location
Automatic Memory Management:
In languages like C and C++ any dynamic memory which the programmer allocates using malloc( ) or new has to be deallocated by himself using free( ) or delete
But Java uses runtime automatic garbage collection feature where the JVM itself deallocates any dynamic memory which our program allocated.
[/vc_column_text][/vc_column][/vc_row]