# Features of Java

&#x20;Features of a language are nothing but the set of services or facilities provided by the language vendors to the industry programmers. Some important features of java are

* &#x20;Simple&#x20;
* &#x20;Platform Independent&#x20;
* &#x20;Architectural Neutral&#x20;
* &#x20;Portable&#x20;
* &#x20;Multi-Threading&#x20;
* Distributed&#x20;
* &#x20;Robust&#x20;
* &#x20;Dynamic&#x20;
* Secured&#x20;
* High Performance&#x20;
* &#x20;Interpreted
* &#x20;Object Oriented

### &#x20;1. Simple

* &#x20;It is simple because of the following factors:&#x20;
* &#x20;It is free from pointer due to this execution time of application is improve.&#x20;
* &#x20;It has Rich set of API (application protocol interface).&#x20;
* It has Garbage Collector which is always used to collect un-Referenced (unused) Memory location for improving performance of a Java program.
* It contains user friendly syntax for developing any applications.

#### &#x20;Define an API

&#x20;An application program interface (API) is a set of routines, protocols, and tools for building software applications. A good API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together.

#### &#x20;Define Garbage Collector

&#x20;Garbage Collector is the system Java program which runs in the background along with regular Java program to collect un-Referenced (unused) memory space for improving the performance of our applications.&#x20;

Note: java programming does not support destructor concept in place of destructor, we have garbage collector program.

&#x20;Normal Flow of a Java Program

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTWOnOr3jIUgxBqCu4a%2F-LTWRQHYqWJpNxfSlHIl%2Fimage.png?alt=media\&token=27e5e3e1-affd-4492-bbb8-cf77431548e9)

&#x20;Java is a high level programming language. A program written in high level language cannot be run on any machine directly. First, it needs to be translated into that particular machine language. The javac compiler does this thing, it takes java program (.java file containing source code) and translates it into machine code (referred as byte code or .class file).&#x20;

Java Virtual Machine (JVM) is a virtual machine that resides in the real machine (your computer) and the machine language for JVM is byte code. This makes it easier for compiler as it has to generate byte code for JVM rather than different machine code for each type of machine. JVM executes the byte code generated by compiler and produce output. JVM is the one that makes java platform independent.

&#x20;So, now we understood that the primary function of JVM is to execute the byte code produced by compiler. Each operating system has different JVM; however the output they produce after execution of byte code is same across all operating systems. This means that the byte code generated on Windows can be run on Mac OS and vice versa. That is why we call java as platform independent language. The same thing can be seen in the diagram below:

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTWOnOr3jIUgxBqCu4a%2F-LTWRnVq2bLVsiBd8xuL%2Fimage.png?alt=media\&token=5ae5084f-c0ee-45ea-93b7-9c0223fef7e8)

#### &#x20;Key Points:&#x20;

&#x20;The Java Virtual machine (JVM) is the virtual machine that runs on actual machine (your computer) and executes Java byte code.

* &#x20; The JVM doesn’t understand Java source code, that’s why we need to have javac compiler that compiles \*.java files to obtain \*.class files that contain the byte codes understood by the JVM.&#x20;
* &#x20;JVM makes java portable (write once, run anywhere). Each operating system has different JVM; however the output they produce after execution of byte code is same across all operating systems.

&#x20; Note:Java is platform Independent but JVM is platform dependent because every Operating system has different-different JVM which is install along with JDK Software.

&#x20;JRE: JRE is the environment within which the java virtual machine runs. JRE contains Java virtual Machine (JVM), class libraries, and other files excluding development tools such as compiler and debugger.

Which means you can run the code in JRE but you can’t develop and compile the code in JRE.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTa-wzCkYus6819cqwd%2F-LTa36szzCjwcUOnJIwt%2Fimage.png?alt=media\&token=9eea31a0-d820-4259-a7c8-90fdaabc9942)

&#x20;JDK: JDK is a superset of JRE, it contains everything that JRE has along with development tools such as compiler, debugger etc. It physically exists. It is collection of programming tools and JRE, JVM.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTa-wzCkYus6819cqwd%2F-LTa3GXVWUYD8R_Pe93W%2Fimage.png?alt=media\&token=54d10c6a-b5a9-4dba-b8ec-4a0f6e25fd2f)

#### &#x20;Definition of JIT

&#x20;JIT is the set of programs developed by SUN Micro System and added as a part of JVM, to speed up the interpretation phase.

#### &#x20;2. Platform Independent

&#x20;A program or technology is said to be platform independent if and only if which can run on all available operating systems with respect to its development and compilation. (Platform represents O.S).

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTa-wzCkYus6819cqwd%2F-LTa3hTd13kmx_5AxHu2%2Fimage.png?alt=media\&token=4bd4614b-60c5-4ee1-8dfa-f6ac0549d38d)

#### &#x20;3. Architectural Neutral

&#x20;Architecture represents processor.

&#x20;A Language or Technology is said to be Architectural neutral which can run on any available processors in the real world without considering their architecture and vendor (providers) irrespective to its development and compilation.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTa-wzCkYus6819cqwd%2F-LTa42HefHwpJK5xIxY2%2Fimage.png?alt=media\&token=6c884980-aebc-4195-9254-d3818d66278c)

#### &#x20;4. Portable

&#x20;If any language supports platform independent and architectural neutral feature known as portable. The languages like C, CPP, Pascal are treated as non-portable language. It is a portable language.

&#x20;According to SUN microsystem.

* &#x20;**Platform Independent + Architecture Neutral = Portability**

#### &#x20;5. Multithreaded

&#x20;A flow of control is known as thread. When any Language execute multiple thread at a time that language is known as multithreaded Language. It is multithreaded Language because of below reason.

&#x20;When we execute any java program, the logic of the java program is executed by one of the thread known as foreground thread. To monitor the execution status of foreground thread one more thread is created known as background thread.so java program is containing 2 threads. Hence every java program is multi-threaded.

#### &#x20;6. Distributed

&#x20;Using this language, we can create distributed application. RMI and EJB are used for creating distributed applications. In distributed application multiple client system are depends on www.testingbar.com Sujoy@testingbar.com multiple server systems so that even problem occurred in one server will never be reflected on any client system.

#### &#x20;7. Robust

&#x20;Simply means of Robust is strong. It is robust or strong Programming Language because of its capability to handle Run-time Error, automatic garbage collection, lack of pointer concept, Exception Handling. All these points make It Robust Language.&#x20;

#### 8. Dynamic

&#x20;It supports Dynamic memory allocation due to this memory wastage is reduce and improve performance of application. The process of allocating the memory space to the input of the program at a run-time is known as dynamic memory allocation, to programming to allocate memory space by dynamically we use an operator called 'new' 'new' operator is known as dynamic memory allocation operator.

#### &#x20;9. Secure

&#x20;In Java programming we have a dedicated APIs (Libraries) for dealing with security. Whereas non-Java programming language (C,C++) there is no existing libraries for security.

#### &#x20;10. High performance

&#x20;It has high performance because of following reasons;

* &#x20;This language uses Bytecode which is faster than ordinary pointer code so Performance of this language is high.&#x20;
* &#x20;Garbage collector, collect the unused memory space and improve the performance of application.
* &#x20; It has no pointers so that using this language we can develop an application very easily.

#### &#x20;11. Interpreted&#x20;

It is one of the highly interpreted programming languages.

&#x20;www.testingbar.com Sujoy@testingbar.com Java bytecode is translated on the fly to native machine instructions which makes development process more rapid

#### &#x20;12. Object Oriented

&#x20;Java is a purely object oriented programming language as its follow all the 5 features of Object oriented programming System. These features are&#x20;

1\. Class and Object

&#x20;2\. Encapsulation

&#x20;3\. Abstraction

&#x20;4\. Inheritance

&#x20;5\. Polymorphism

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTa-wzCkYus6819cqwd%2F-LTa5e8cYLtFbXQhYyGq%2Fimage.png?alt=media\&token=fa21c836-4545-4bdd-a8d9-d01c39cc471c)

