Here we are going to discuss about some important question and answers for interview preparation.

1. What do you know about Java?
Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

2. What are platforms which is supported by Java Programming Language?
Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.

3. What is difference between JDK,JRE and JVM?
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.

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

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:
1. Runtime Environment
2. API(Application Programming Interface)

5. What gives Java its ‘write once and run anywhere’ nature?

The bytecode. Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platform specific and hence can be fed to any platform.

6. What do you mean by Object?

Object is a runtime entity and it’s state is stored in fields and behavior is shown via methods. Methods operate on an object’s internal state and serve as the primary mechanism for object-to-object communication.

7. Define class? What kind of variables a class can consist of?

A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

A class consist of Local variable, instance variables and class variables.

Local Variable: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.


class Book{

Book(){ //This is default constructor

String writer; //here writer is a local variable for this constructor and we cannot use this outside the constructor.



Class Variable: These are variables declared with in a class, outside any method, with the static keyword.


class Book{

static String writer;// here writer is class variable and can be accessed by class name


8. What do you mean by Constructor?

Constructor gets invoked when a new object is created. Every class has a constructor. If we do not explicitly write a constructor for a class the java compiler builds a default constructor (without any parameter constructor is called default constructor) for that class.

9. What will be the initial value of an object reference which is defined as an instance variable?

The object references are all initialized to null in Java.

10. What is static variable?

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.

1,334 total views, 2 views today