MenuBar

Sunday, 3 April 2011

tutorial no 2: Java virtual mechine, compilation and data types

hay guys, This Is usman and today we will be learning about java virtual machine how a programme get compiled and  run on a computer also we will see what are data types.
First of all we see the life cycle of java program. In The First Step  we write source code. This Source Code is Read Able by Human. but we are programing computer not human:p Then we hand This Source Code To our Java compiler. Java compiler compiles our .java File into .class file Which contains byte code. but still this byte code is not readable by computer and either human so? the byte code generated by java compiler is readable by some thing called java virtual machine (JVM).java virtual machine reads this byte code and converts it into machine language that computer understands.finally our computer is able to read our program and runs it.
unlike c++ and other languages, Java is a platform independent language.For example, if we write a program in c++ in a window enviornment, and when we compile it it generate machine code, this code is directly readable by our operating system.well, that's nice, but what if some one said to you to run that same code on Mac, Linux or UNIX? You have to compile the source code again for Mac, Linux or UNIX. but not in java. see java is plate form independent if you write a programme and compile it, you got a .class file. if you make this .class file in xp environment then you can also run it on a Mac too. all you have to do is to give this file to java virtual machine of that operating system it will automatically converts it into machine language that your operating system understands. how cool is that?click here
There are Two Types of data types 
                         1=> primitive data types
                         2=>reference data types 
primitive types are some basic types like int, char, long, double etc and reference types are like objects of a class, if we do this  int a = 12; then "a"  is a primitive types. if we made a class called student then  student Stu; then Stu is of reference type.
there are also some wrapper classes like Integer, Long, Double etc these classes contains some static method which are used to modify data types.  static methods are methods which are not accessible by our object of that class. we put class name.method. any way if you don't get it just stick with me . we will be learning methods.

No comments:

Post a Comment