are the key features of why java has gained its importance in the market..and let me tell u java was exclusively invented to implement its features on buisness side than on system-side applicationz...so lets have a clear idea on its key features
PLATFORM INDEPENDENCY:
what is a PLATFORM??
Machine + architecture is called Platform.
The ability of a program to run on any system irrespective of the operating system that is present is called PLATFORM INDEPENDENCY.
C is not platform independent coz the executable code of it cannot run on all operating system. It is confined to operating systems,whereas java runz on an operating system, what makes java program to run on any operating system is JVM, before that lets learn what is source code and executable code????
SOURCE CODE: Any thing which is understandable by the user or programmer is called source code,usually the programz that we write following some syntactic rules is called source code,now this source code can run on any operating system
For example lets take
void main()
{
printf("halo world");
}
this C source code can work on any operating system..(u can check it practically too) then y do we call C as a platform dependent if its source code is running on all operating-systems..well!! here exactly we need to discuss something about Compiled code and executable code.
WHAT IS COMPILED CODE?
Every source code is converted into compiled code in order to make computer understand what the user wants to do,hence compiled code is the binary format which a computer can understand.
Now,in C,compiled code is executable code, this executable code is something which is machine dependent and varies from operating system to operating system,because every operating-system is designed according to its own standards so when u try to run the compiled code of one machine on other machine,definetly u would fail in doing the task coz the machines are not compatible with each other and cant understand each other's code,hence compiled code cannot be run on different systems,hence C is purely platform dependent...
Now u may have a question of why cant we directly run the source code every time....wats the big deal with compiled code..???
Well! In real time scenario, we can't take risk to give a source code to our clients,the obvious reason is we will run out of buisness in case we do it,hence we always prefer to give compiled code or executable code(in this case) to the clients,hence we need the concept of platform independency i.e the ability of a program to run on any OS(operating system).
Now how java is platform independent??
Java is platform independent because it has the concept of JVM..
before we know what is JVM,lets get into little deep into the concept of compiled code..
Every compiled code need not be executable code,in case of java a compiled code is a byte code,later on this byte code is converted into executable code by JVM.
An obvious question... what is Byte code??
Byte code is also a format which is understandable by computer but it is not in the binary format instead it is in the assembly language format,a combination of alpha numerics and few symbols,(where as binary format is purely 1's and 0's).
So,every java program is firstly converted into byte code and then this byte code is lateron converted to executable code by JVM and is run on machines.
Another obvious question i can expect is when JVM converts byte code into executable code according to machine format,it is obvious that JVM is platform dependent, then how can we say that java is platform independent..
hmm!! It is because JVM is small in size,easily downloadable,fast and hence we do not really take the existence of java into account and hence we run the programz
Remember,JVM is designed compatible to the operating system,hence from OS to OS only JVM varies,thus JVM makes Java Platform independent..
In my next blog we shall see what is JVM,how ever the remaining features of java will be discussed according to the situations we encounter as and when..
I will be happy to see ur comments and doubts in case if u have any