Java Interview Question and Answers

Tuesday, October 2, 2012

Questions : 1 What is JVM (Java Virtual Machine) ?
Answers : 1
JVM stands for Java Virtual Machine. It’s an abstract computer or virtual computer which runs the compiled java programs. Actually JVM is a software implementation which stands on the top of the real hardware platform and operating system. It provides abstraction between the compiled java program and the hardware and operating system. So the compiled program does not have to worry about what hardware and operating system he has to run in, it’s all handled by the JVM and thus attaining portability. All Java programs are compiled in to bytecodes. JVM can only understand and execute Java bytecodes. we can visualize Java bytecodes as machine language for JVM. Java compiler takes the .java files and compiles it to a “bytecode” file with .class file extension. Compiler generates one class file for one source file.
   
Questions : 2 What is JIT (Just-in-Time) Compilation ?
Answers : 2
When JVM compiles the class file he does not compile the full class file in one shot. Compilation is done on function basis or file basis. Advantage gained from this is that heavy parsing of original source code is avoided. Depending on need basis the compilation is done. This typ of compilation is termed as JIT or Just-in- Time compilation.
   
Questions : 3 How do you implement inheritance in Java?
Answers : 3
nheritance is implemented by using “EXTEND” keyword.