Showing posts with label Top 9 Basic Questions of Java. Show all posts
Showing posts with label Top 9 Basic Questions of Java. Show all posts

Sunday 26 June 2016

Top 9 Basic Questions of Java


Questions 1:- Why java program is platform independent ? Why not C and C++  program ?
Answer:- When we compile c source data, it generate the “native code” which can be understood  by current operating System, if Move to this to other operating System. It cannot be understood because ” Native code representation is change from operating system to operating system”. So, C and C++ Program is not platform independent.
In case of java source code, compilation you will get “ byte code firstly instead of native code”. When you run the byte code, it will be converted to native code and then it will be executed. But native code generated from the byte code is temporary and will not be stored in any file. If you want to run the java program in other operating system, just move the byte code and run again. When you run your byte code will be converted to native code again and will be executed. So, Java Program  is platform independent.

Question 2:- What is JDK ?
Answer:-  JDK stands for Java Development Kit which contains tools to compile and run a java program.

Question 3:- What  is JVM ?
Answer:-JVM is java run time environment which provides the necessary supports to run over java program.



Question 4:- What is Java Compile ?
Answer:- Java Compiler is single non java program which is used to verify the programmatically mistake in the source code and also convert the source code to bytecode.

Question 5:- What is Interpreter ?
Answer:- Java interpreter is single non java program which is used to convert byte code to native code and also to execute native code. 

Question 6:- What is JIT compiler ?
Answer:- JIT is the part of the Java Virtual Machine (JVM) that is used to speed up the execution time. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation. Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.

Question 7:- Which of the following statements are true ?
1.     Java compiler is platform independent .                  (False)
2.     Java interpreter is platform dependent.                    (True)
3.     Java program is platform independent.                    (True)
4.     JVM is platform dependent.                                     (True)
5.     C program is platform independent.                         (False)
6.     JDK platform dependent.                                         (True)
7.     JIT compiler is platform dependent.                        (True)

Question 8:-  Why we have to set the path ?
Answer:-  We need to set the path for executable file to access anywhere with in the operating system drives and folder. Similarly with class path same.

Question 9:- Why we need to use % path %  in the path setting.
Answer:- This is to append the current path to the existing path. If we are not using %path % then existing path will be replaced with new path. Similarly class path same.

Path sets for bin folder where .exe files available.
Class path sets for lib folder where jar file available.