Monday 3 September 2018

Introduction to Java (Part -3 )




*Question - How can you say "Java is Platform Independent"?

Answer - 

Before Understanding this Question, Let's understand "What is Platform? "
The platform is the combination of the processor of a system and the Operating system that is installed in your system.

[ Platform = System Processor  +  Operating System ]

Now,
decide Java is platform Independent or not?




Yes, Java is platform Independent because, in the image, there is only one JAVA APPLICATION and that application can able to execute (run) on three different machines (Windows, MacOS and Linux).
So we can say that Java is a PLATFORM INDEPENDENT Language
BUT JVM IS PLATFORM DEPENDENT.


Question - Prove that "JAVA is Platform Independent"?

Answer -



  1. Write Java program and save it as abc.java 
  2. Compile it and get equivalent byte code or class file (abc.class)
  3. Now the code is ready to execute...
  4. In the client machine (System in which code is going to run), JVM convert your Byte Code into Machine Code 
  5. Now that Machine Code is dependent and it is going to run in your system.
According to the question, write a java code(program) and compile it and get the equivalent Byte Code.Now you can able to use that bytecode in any Machine (System).

[Note- JVM should be installed at that Machine(System)]


Question - What is BYTE CODE?
Answer - BYTE CODE is the equivalent code of your JAVA Program(code).


Question - Why it is called BYTE CODE?
Answer - Because the length of each instruction is of 8 bit.





No comments:

Post a Comment