Tuesday, May 5, 2009

Java Interview Questions

1. What are JDK, JRE and JVM ?
A. JDK: Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…

Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.

You need JDK, if at all you want to write your own programs, and to compile them. For running java programs, JRE is sufficient.

JRE: Java Runtime Environment contains JVM, class libraries, and other supporting files. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system.

JVM: Java Virtual Machine interprets the bytecode into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.

The JVM is called "virtual" because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.

2. What are the OOPS Concepts?
A. The four basic pillars of OOPS are Abstraction, Encapsulation, Polymorphism and Inheritance.



3. Explain about Abstraction, Encapsulation, Polymorphism, and Inheritance?
A.


4.What is a Class and Object?
A.

5.What is an Interface?
A.

6.What is an Abstract Class?
A.

7.When do you go for an Abstract Class and an Interface?
A.

8.How do you achieve Polymorphism in Java?
A.

9.What are the access modifiers in Java?
A.

10.What is the significance of static, final, finally, finalize keywords?
A.

11.Explain why the main method has public, static and void modifiers in Java?
A.

2 comments: