On this page, you will learn about the features of Java, according to SUN the primary objective of creating the Java language was to make it a portable, simple and secure programming language.
Apart from this, there are also some excellent features which play an important role in the popularity of this language among developers.
The features of Java are also known as Java buzzwords.
1. Simple
Java is very easy to understand, and its syntax is simple, clean and easy to learn.
According to Sun Microsystems, Java is a simple programming language because:
- Java syntax is based on C++ so, if the coder has a basic knowledge of C++, then it will be easy to understand.
- Java has removed many complicated and rarely-used features, like explicit pointers, operator overloading, etc.
- There is no need to remove unreferenced objects in Java Language because there is an Automatic Garbage Collection in it.
2. Object-oriented
Java is a pure object-oriented programming language.
Actually, this is one of the primary reasons why Java is so popular among developers just because it strictly follows the rules of oop’s concept.
OOP is a methodology or paradigm to design a program using classes and objects. OOP simplifies software development and maintenance by providing concepts like:
- Object
- Class
- Inheritance
- Polymorphism
- Abstraction
- Encapsulation
3. Robust
Robust means ‘strong’. Does it mean it can lift a mountain? Certainly not.
Java is robust because:
- It uses strong memory management techniques to exclude improper memory assignments in programs.
- There is no pointer that avoids security problems. This means malicious code can use explicit pointers to get accessed the restricted data.
- There is automatic garbage collection in Java which runs on the JVM to get rid of objects which are not being used by a Java application anymore.
- There are exception handling and the type checking mechanism in Java which makes the language more robust.
4. Portable
Java is considered a portable language.
More precisely, Java bytecode is portable.
The output of the Java compiler is non-executable code i.e. bytecode. This Java bytecode is portable in nature as it can be executed on multiple platforms (Linux, Windows, Mac) by JVM.
5. Platform Independent
Platform means any hardware or software in which a program runs.
Unlike C or C++, Java doesn’t need to be dependent on a specific system for the execution of code. Java is a write-once, run-anywhere (WORA) language.
Java source code gets converted in bytecode after compilation when javac is used.
And, this bytecode can be executed on several platforms (Linux, Windows, docs, Sun Solaris, etc) independent of hardware or O.S used, with the help of Java run-time system JVM.
For this, only you need to install platform-dependent JVM on your system to execute the code.
6. Secure
Java is a more secure language than C or C++, how?
- No explicit pointer: Malicious code can use explicit pointers to get access inside the restricted data but, due to no explicit pointer in Java, security problems can be avoided.
- Java Programs run inside a virtual machine sandbox
- Classloader: In Java, Classloader is a part of the Java Runtime Environment(JRE) which is used to load Java classes into the Java Virtual Machine dynamically. It adds security to the language by separating the package for the classes of the local file system from those that are imported from network sources.
- Bytecode: Every time when a user compiles the Java program, the Java compiler creates a class file with Bytecode, this bytecode is again tested by the JVM itself at the time of program execution for viruses and other malicious files.
7. Interpreted
Java is considered an interpreted language.
As Java is neither fully interpreted nor compiled, it is a combination of both.
First, the source code gets compiled into a .class file i.e. bytecode to get understood by JRE.
After that, bytecode is interpreted by the JVM making it an interpreted language.
8. Distributed
Java is also a distributed language because:
- It facilitates users to create distributed applications in Java.
- RMI and EJB are used for creating distributed applications in Java.
- This feature of Java makes us able to access files by calling the methods from any machine on the internet.
9. No Pointers
In Java, we have the concept of references, not the pointers. References store the address of the object in memory.
Reasons to not use pointer:
- The first and very important reason is security. The concept of pointers in C or C++ language is often misused by malicious code as the pointers can be manipulated but the references can’t be manipulated.
- To make the program simple, they have eliminated pointers. Java doesn’t support pointer explicitly but, it supports pointers implicitly i.e. it is not visible to users.
- To create a garbage collection, which was quite impossible to implement if pointers were available. With the use of references only, it is possible to construct efficient garbage collector algorithms that can eliminate memory fragmentation.
10. Dynamic
Dynamic means which is always active or keeps changing according to need.
In a programming language, Dynamic refers to the classes which are loaded on demand during runtime.
Java bytecode facilitates the language to be called as dynamic because the source code which is written in one platform, that code can be executed in any platform. It loads the class file during runtime only.
Hence, anything that takes place in runtime is dynamic in nature.
11. Multi-Threading
Multi-threading means a program which allows multiple threads to run in parallel. According to this feature of the OOP concept, OS divides processing time not only among different applications but also among each thread within an application.
Multi-threading provides a feature to write Java programs that deal with many tasks at once by defining multiple threads.
The main advantage of multi-threading is that it doesn’t occupy memory for each thread instead, it uses a common memory area.
12. High Performance
As we are aware that compiler execution is faster than the interpreter.
But, Java is favourite among developers and it is considered a faster language than any other interpreted language.
Java enables high performance only because of the JIT, Just in Time compiler.
JIT helps the compiler to compile the codes on the basis of methods called i.e. it compiles only that block of method which is being called to make the performance better and faster.
13. No Global Variables
C or C++ languages use the global variable in their code which is declared at the start of the program and accessible throughout the program.
But in Java, there is no concept of the global variable. In Java, static variables are declared, and they can be available for all instances of the class.
Leave a Reply