TOP 10
JAVA INTERVIEW
QUESTIONS &
ANSWERS 2014
SOURCE -> hirist.com
What is JVM?
Why is Java
called the
‘Platform
Independent
Programming
Language’?
#1
Java Virtual Machine, is an interpreter
which accepts „Bytecode‟ and executes it.
It primarily works on the notion of
„compile once, run everywhere‟.
The translation into Bytecode makes a
program easier to be executed across a
wide range of platforms
JVMs for various platforms might vary
in configuration but they all understand
the same set of Bytecode




SOURCE -> hirist.com
Which two
methods do
you need to
implement for
key Objects in
HashMap ?
#2
It must implement equals and
hashcode method in Java
Equals and hashcode method is
used to put and get object from
HashMap


SOURCE -> hirist.com
What is
the
Difference
between
JDK and
JRE?
#3
The “JDK” is the Java Development Kit. i.e.,
the JDK is bundle of software that you can
use to develop Java based software
The “JRE” is the Java Runtime
Environment. I.e., the JRE is an
implementation of the Java Virtual
Machine which actually executes Java
programs.
Each JDK contains one (or more) JRE‟s
along with the various development tools
like the Java source compilers, bundling
and deployment tools, debuggers,
development libraries, etc.



SOURCE -> hirist.com
What is
immutable
object? Can
you write
immutable
object?
#4
Immutable classes are Java classes
whose objects can not be modified once
created
Any modification in Immutable
object result in a new object
For example, is String is immutable in
Java



SOURCE -> hirist.com
What are
the Data
Types
supported
by Java?
#5
There are eight Primitive Data types
supported by Java
• Byte : 8-bit signed two‟s complement
integer
• Short : 16-bit signed two‟s complement
integer.
• Int : 32-bit signed two‟s complement
integer.
• Long : 64-bit signed two‟s complement
integer.
• Float, Double, Autoboxing, Unboxing


SOURCE -> hirist.com
www.hirist.com
Handpicked Java Jobs
What is
Autobox
ing and
Unboxin
g?
#6
Autoboxing: The Java compiler brings
about an automatic transformation of
primitive type (int, float, double etc.) into
their object equivalents or wrapper type
(Integer, Float, Double,etc) for the ease
of compilation.
Unboxing: The automatic
transformation of wrapper types
into their primitive equivalent is
known as Unboxing.


SOURCE -> hirist.com
What is
Function
Over-Riding
and Over-
Loading in
Java?
#7
Over-Riding: An override is a type of function
which occurs in a class which inherits from another
class. An override function “replaces” a function
inherited from the base class, but does so in such a
way that it is called even when an instance of its
class is pretending to be a different type through
polymorphism.
Over-Loading: Overloading is the action of
defining multiple methods with the same name,
but with different parameters. It is unrelated to
either overriding or polymorphism. Functions in
Java could be overloaded by two mechanisms
ideally:
• Varying the number of arguments.
• Varying the Data Type.


SOURCE -> hirist.com
What is the
difference
between Ar
ray List
and Linked
List ?
#8
Array List
- Random access
- Only objects can be added
Linked List
- Sequential access
- Implemented using nodes linked to
each other


SOURCE -> hirist.com
What is
difference
between
CyclicBarrier
and
CountDownLa
tch in Java
#9
Main difference between both of
them is that you can
reuse CyclicBarrier even if
Barrier is broken but you cannot
reuse CountDownLatch in Java.

SOURCE -> hirist.com
What is
the use of
the
‘SimpleDa
teFormat’
#10
SimpleDateFormat is one such concrete
class which is widely used by Java
developers for parsing and formatting of
dates. This is also used to convert Dates
to String and vice-versa..
Almost every Enterprise level Java
Application invariably uses the
SimpleDateFormat for handling user
dates


SOURCE -> hirist.com
Hirist.com
Handpicked Java Jobs

Top 10 Java Interview Questions and Answers 2014

  • 1.
    TOP 10 JAVA INTERVIEW QUESTIONS& ANSWERS 2014 SOURCE -> hirist.com
  • 2.
    What is JVM? Whyis Java called the ‘Platform Independent Programming Language’? #1 Java Virtual Machine, is an interpreter which accepts „Bytecode‟ and executes it. It primarily works on the notion of „compile once, run everywhere‟. The translation into Bytecode makes a program easier to be executed across a wide range of platforms JVMs for various platforms might vary in configuration but they all understand the same set of Bytecode     SOURCE -> hirist.com
  • 3.
    Which two methods do youneed to implement for key Objects in HashMap ? #2 It must implement equals and hashcode method in Java Equals and hashcode method is used to put and get object from HashMap   SOURCE -> hirist.com
  • 4.
    What is the Difference between JDK and JRE? #3 The“JDK” is the Java Development Kit. i.e., the JDK is bundle of software that you can use to develop Java based software The “JRE” is the Java Runtime Environment. I.e., the JRE is an implementation of the Java Virtual Machine which actually executes Java programs. Each JDK contains one (or more) JRE‟s along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.    SOURCE -> hirist.com
  • 5.
    What is immutable object? Can youwrite immutable object? #4 Immutable classes are Java classes whose objects can not be modified once created Any modification in Immutable object result in a new object For example, is String is immutable in Java    SOURCE -> hirist.com
  • 6.
    What are the Data Types supported byJava? #5 There are eight Primitive Data types supported by Java • Byte : 8-bit signed two‟s complement integer • Short : 16-bit signed two‟s complement integer. • Int : 32-bit signed two‟s complement integer. • Long : 64-bit signed two‟s complement integer. • Float, Double, Autoboxing, Unboxing   SOURCE -> hirist.com
  • 7.
  • 8.
    What is Autobox ing and Unboxin g? #6 Autoboxing:The Java compiler brings about an automatic transformation of primitive type (int, float, double etc.) into their object equivalents or wrapper type (Integer, Float, Double,etc) for the ease of compilation. Unboxing: The automatic transformation of wrapper types into their primitive equivalent is known as Unboxing.   SOURCE -> hirist.com
  • 9.
    What is Function Over-Riding and Over- Loadingin Java? #7 Over-Riding: An override is a type of function which occurs in a class which inherits from another class. An override function “replaces” a function inherited from the base class, but does so in such a way that it is called even when an instance of its class is pretending to be a different type through polymorphism. Over-Loading: Overloading is the action of defining multiple methods with the same name, but with different parameters. It is unrelated to either overriding or polymorphism. Functions in Java could be overloaded by two mechanisms ideally: • Varying the number of arguments. • Varying the Data Type.   SOURCE -> hirist.com
  • 10.
    What is the difference betweenAr ray List and Linked List ? #8 Array List - Random access - Only objects can be added Linked List - Sequential access - Implemented using nodes linked to each other   SOURCE -> hirist.com
  • 11.
    What is difference between CyclicBarrier and CountDownLa tch inJava #9 Main difference between both of them is that you can reuse CyclicBarrier even if Barrier is broken but you cannot reuse CountDownLatch in Java.  SOURCE -> hirist.com
  • 12.
    What is the useof the ‘SimpleDa teFormat’ #10 SimpleDateFormat is one such concrete class which is widely used by Java developers for parsing and formatting of dates. This is also used to convert Dates to String and vice-versa.. Almost every Enterprise level Java Application invariably uses the SimpleDateFormat for handling user dates   SOURCE -> hirist.com
  • 13.