Features of Java

Simple

Java is simple because:

  • It has user friendly syntax. Code is easy to read and write.
  • It has removed complex and confusing elements like pointers, operator overloading, goto jump etc.
  • It has automatic garbage collector which collects unreferenced objects. Programmers do not need to bother about unreferenced objects.

Secure

Java is said to be secure because:

  • It provides automatic memory management, garbage collection, and range-checking on arrays. This leads to fewer programming errors and to safer, more robust code.
  • Java language defines different access modifiers that can be assigned to Java classes, methods, and fields, enabling developers to restrict access to their class implementations as appropriate and making code safer.
  • A compiler translates Java programs into a machine-independent bytecode representation. A bytecode verifier is invoked to ensure that only legitimate bytecodes are executed in the Java runtime.
  • In Java, you cannot access out-of-bound arrays, and you don't have pointers, and thus several security flaws like stack corruption or buffer overflow is impossible to exploit in Java.
  • Java applications run in a virtual machine sandbox that prevents them from doing any harm to the system they are running on.

Java provides many other security features through it's java.security package.

Object Oriented

Java is an object oriented programming language. It supports all OOP(Object Oriented Programing) concepts. Basic OOPs concepts are given below:

  • Object
  • Class
  • Polymorphism
  • Inheritance
  • Encapsulation
  • Abstraction

See more: OOPs concepts in detail

Platform Independent

Java is platform independent because Java programs run in JVM (Java Virtual Machine) and JVM is available for all platforms i.e MAC, Windows, Linux etc. So you can compile your code in any platform/OS and then run the generated bytecode in any other platform/OS. This is why Java is said to be "Write once and Run Anywhere (WORA)"

In other words, the program you write in java has no dependency on your operating system. If you think, you will find that it is JVM which is platform dependent and it allows your code to be platform independent.

Portable

Java is portable because you can carry the Java bytecode any where. You can compile your Java code in your system, then you can carry the generated bytecode in your hard disk/pendrive and run it in your friends machine or anywhere else.

Interpreted

Technically Java is both compiled and interpreted. Rather than compile straight to executable machine code, it compiles to an intermediate binary form called bytecode. The bytecode is then interpreted or compiled by JVM to run the program. I have used interpreted or compiled because depending on the execution environment (implementation of JVM), bytecode can be:

  • Compiled ahead of time and executed as native code (similar to most C++ compilers).
  • compiled just-in-time (by JIT compiler) and executed.
  • Interpreted
  • Directly executed by a supported processor (bytecode is the native instruction set of some CPUs).

Robust

Robust means strong and healthy. Java programs are robust because of it's strong security features, capability to handle runtime errors and strong memory management.

Distributed

Java is distributed. It means we can create distributed applications in Java. A distributed application is software that is executed or runs on multiple computers within a network. It is mostly used in client-server model. Java RMI and EJB are used for creating distributed applications.

Dynamic

Java is Dynamic because:

  • Java loads all the classes and jars and libraries from hard drive at the runtime .
  • Java support dynamic binding which is also know as late binding or run-time binding. Java method overriding is an example of dynamic binding.
  • Java supports dynamic memory allocation which eliminates the waste of memory and loss of data.

Multi-threaded

Java is multi-threaded. We can write multi-threading code in Java. A thread is an independent path of execution. When many threads run concurrently it's called multi-threading.

High Performance

Java uses Just-In-Time compiler which enable high performance is Java. But Java is still slower than a compiled language e.g. C++

Architectural Neutral

Java is architectural neutral. It means Java code acts same with platforms of different architecture(32 bit/64 bit). For example: in C language size of int data type is 2 bytes in 32-bit OS and 4 bytes in 64-bit OS but size of int in Java is same in both.