Java Interview Questions

Below 200+ 200+ core java interview questions. We assure that you will get here the 90% frequently asked interview questions and answers.
The answers of the core java interview questions are short and to the point. The core java interview questions are categorized in Basics of java interview questions, OOPs interview questions, String Handling interview questions, Multi-threading interview questions, collection interview questions, JDBC interview questions etc.
Whether you are a fresher or highly experienced professional, core java plays a vital role in any Java/JEE interview. Core Java is the favorite area in most of the interviews and plays a crucial role in deciding the outcome of your interview. This post is about core java interview questions that comes directly from my 10+ years of java programming and lots of interviewing experience.

Question-1. What is difference between JDK,JRE and JVM ?

Answer-

JVM: JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which java bytecode can be executed. It is a specification.

JVMs are available for many hardware and software platforms (so JVM is platform dependent).

JRE: JRE stands for Java Runtime Environment. It is the implementation of JVM.

JDK: JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.

 

Question-2. How many types of memory areas are allocated by JVM ?

Answer-

a.  Class(Method) Area
b.  Heap
c.  Stack
d.  Program Counter Register
e.  Native Method Stack

 

Question-3. What is platform ?

Answer- A platform is basically the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides software-based platform.

Question-4. What is the main difference between Java platform and other platforms ?

Answer- The Java platform differs from most other platforms in the sense that it’s a software-based platform that runs on top of other hardware-based platforms.It has two components:

a.  Runtime Environment
b.  API(Application Programming Interface)

 

Question-5. What is constructor ?

Answer- Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation.

Question-6. What is the purpose of default constructor ?

Answer- The default constructor provides the default values to the objects. The java compiler creates a default constructor only if there is no constructor in the class.

Question-7. Does constructor return any value ?

Answer- Yes, that is current instance (You cannot use return type yet it returns a value).

Question-8. Is constructor inherited ?

Answer- No, constructor is not inherited.

Question-9. Can you make a constructor final ?

Answer- No, constructor can’t be final.

Question-10. What is static variable ?

Answer- static variable is used to refer the common property of all objects (that is not unique for each object) e.g. company name of employees,college name of students etc.
static variable gets memory only once in class area at the time of class loading.