Sunday, May 18, 2014

WBUT Java Sample Question and Answer 1

Q1. Why Java is called platform independent?


Ans: Java is platform independent because a compiled java dot class file could be executed on different platform (that is operating system) without re-compiling on those platforms. We can compile a java source code on one operating system and can execute the object code (a dot class file) on any other operating system provided the target operating system is installed with Java Runtime Environment.

Q2. How Java is platform independent?

Ans: Java achieves platform independence using a two tier system of compilation and execution. Java compiler compiles the Java source code and generates java dot class file/s in a specific format called byte code. This dot class file has to be submitted to the Java Virtual Machine (JVM) of the target system for execution;   JVM interprets the dot class file according to the underlying operating system and executes the java program.
Sun-micro-system launched different versions of virtual machines for different operating system and they were made freely available. It is the JVM that makes the Java independent of operating system. 

Q3. Describe JDK, JRE, JVM.

Ans: 
JDK –  It is Java Development Kit, contains Java compiler, Java Runtime Environment and Standard java runtime library along with the other necessary tool (Applet viewer, rmic ) to develop standard java applications. For developing Java application a programmer need JDK.
JRE – Java Runtime Environment,  it contains everything that is necessary for executing a java compiled code, JRE contains JVM (Java Virtual Machine), Runtime classes, library, Java class loader.
JRE could be downloaded independently or it is available within JDK.
JVM- Java Virtual Machine is subpart of JRE, it contains Just in time compiler to interpret the byte code according to the underlying operating system. JVL also contains garbage collector and exception handler. 






Q4. State some basic features of Java.

  •          Java is platform independent.
  •          It is Object Oriented programming language.
  •          Java library is open source.
  •          No license fee is required for commercial development.
  •         Standard library contains rich set of classes for various purposes.