Features of Java Language

Platform independence being the key feature of the Java language, following features are also to be noted, that makes it the most powerful language among all.

Object Oriented

Java considers everything in terms of objects. This means that all code should be written within a class, including the main().


An object is a real world entity. E.g. – desk, dog. These entities all have a state and behavior. You can refer to the article on Class, Object and the OOP to get yourself more clarified.

The advantages of OOP such as code reusability, modularity etc have been explained by Abhimanyu in the topic ‘Class, Object and the OOP’.

Simple

Java does not have complex features such as pointers, structures, operator-overloading, unions, multiple inheritance etc. Memory allocation and de-allocation is done automatically, making it simpler than others.

Robust

The reliability of the code is checked by the compiler before execution and the interpreter checks for run-time errors. Exception handling, type checking mechanism, initialization of local variables etc. are done implicitly in Java making it robust.

Platform Independent

As I have already mentioned, platform independence is one of the key features of java language. The write-once, run-anywhere concept makes a program platform independent. No programming language has achieved this so far, but java is closest to this concept.

Java is platform independent at both the source and binary level.

  • At source level, Java’s primitive data types have consistent sizes across all development platforms.
  • At binary level, the compiled java byte codes can run on multiple platforms without the need to recompile the source code.

Security

As Java is meant to be used in distributed/networked environments, security plays a major role.

Since memory management is not done by the programmer, Java does not use *explicit memory pointers*, hence reduces misuse.

Java’s security model has 3 main features:

  1. Byte Code Verifier: Checks classes after loading for illegal code that can violate access right to object.
  2. Class Loader: provides security by separating the package for the classes of the local file system from those imported from network sources.
  3. Security Manager: Security manager determines the accessibility options of a class like reading and writing a file to the local disk.

Architecture Neutral

Java is not tied to any particular hardware or OS architecture, i.e. it is machine-independent.

One of the main problems facing programmers was that when you write a program today, there is no guarantee that it will run tomorrow – even on the same machine. To a large extent, this is now guaranteed.

Interpreted and Compiled

The java code is first compiled into byte code and then interpreted by the JVM into machine specific instructions. This provides for double checking the code before execution.

Multi-threaded

Java is also a multithreaded programming language. Multithread means a single program having different threads executing independently at the same time.

Threads are obtained from the pool of available ready to run threads and they run on the system CPUs.

Memory Management and Garbage Collection

Memory management is done automatically using garbage collection by the JVM. Temporary memory is automatically de-allocated after it is no longer referenced by the program. The garbage collector runs in its own low priority thread, improving performance.

Explicit memory pointers

An explicit pointer is a variable that contains a number which refers to an address in memory. An implicit pointer allows you to use that address in memory but does not all you to refer to it by a number.

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.