01 December, 2010

Java Basics

Java is an object oriented programming language. Java is a trademark of Sun Microsystems, Inc. Java started in 1991. It is a platform-independent programming language.A platform is a place to launch software. It means that programmer need not be concerned about the hardware or operating system platform. It is different from C as C compiler produce Machine code or native code which is platform dependent.Machine code or machine language is a system of instructions and data executed directly by a computer's central processing unit(CPU) . Every processor or processor family has its own machine code instruction set. The instruction set is thus specific to a class of processors


               C compiler                      CPU

C Prog. ----------------->m/c code-------------->  o/p


m/c code looks like : mov cx,0x0004

Thus C is platform dependent.

The Java compiler does not produce native executable code for a particular machine like a C
compiler would. Instead it produces a special format called byte code.Java byte code written in
hexadecimal, byte by byte,looks like this:
CA FE BA BE 00 03 00 2D 00 3E 08 00 3B 08 00 01 08 00 20 08

                 JavaC compiler                     JVM                                          CPU
Java Prog--------------------> bytecode----------------> native language------------------> o/p      

Thus Java is platform dependent.   




Difference between Java and C
Java C
Object oriented prog. Procedure oriented prog
No Pointer Uses pointer
automatically garbage collection manually garbage collection using malloc() and free
variables can be declared anywhere variable should be declared in the beginning
Compiled to bytecode Compiled to machine code
Plateform independent Plateform dependent

































No comments: