Java frequently asked interview questions with answers
Latest answer: An abstract class may contain code in method
bodies whereas code is not allowed in an interface..........
Read answer
Latest answer: Synchronized block is better since it places
locks for shorter periods than synchronized methods...........
Read answer
Latest answer: Garbage collection can't be forced, it can
explicitly be called using System.gc(), but there is not guarantee that GC will
be started immediately.............
Read
answer
Latest answer: wait() is defined in the class Object and
sleep() is defined in the class Thread............
Read answer
Latest answer: Constructors have same name as the class and can
not return a value............
Read
answer
Latest answer: Java packages help in organizing multiple
modules. It helps in resolving naming conflicts when different packages have
classes with the same names.............
Read answer
Latest answer: The method equals() is used to compare the
values of the Strings..............
Read answer
Go
top
Latest answer: Native methods are the methods implemented in
other language like C. These methods can be used in Java classes using JNI
API...............
Read answer
Latest answer: The Java class file contains bytecode which is
being interpreted by JVM. Bytecode is introduced in Java to provide Java as
platform independent language.................
Read answer
Latest answer: "this" refers to current object instance.
"super" refers to the member of superclass of the current object
instance..................
Read answer
Latest answer: JAR - Java Archive File is used to package
classes and property files.................
Read
answer
Latest answer: It is the list of directories which is used by
JVM to find a class....................
Read answer
Latest answer: Garbage collector cleans up objects which are no
longer used. It is the thread running as part of JVM
process....................
Read answer
Latest answer: Interning is the process of converting
duplicated strings to shared ones. Interned Strings avoid duplicate
strings..............
Read answer
Go
top
Latest answer: String class is immutable which means it can't
be modified once declared.
StringBuffer is not immutable which means strings can be appended to the
original string..............
Read answer
Latest answer: This class is used to break the string into
tokens............
Read
answer
Latest answer: A thread can be created extending from the
Thread class................
Read
answer
Latest answer: Preemptive scheduling ensures the highest
priority thread to execute until it enters the waiting or dead
states......................
Read
answer
Latest answer: Daemon threads run at a low priority. The GC is
an example of such thread...................
Read answer
Latest answer: Arraylist's methods are not synchronized which
means they are not thread safe. Vector's methods are synchronized which means
they are thread safe..............
Read answer
Latest answer: It is the superclass of all errors and
exceptions in Java.................
Read answer
Go
top
Latest answer: The Finalize method of an
object is called when GC is about to clean up the object. We can keep clean up
code in the finalize block...............
Read
answer
Latest answer: It is the ability of a method to behave
differently based on the kind of input..............
Read answer
Latest answer: It is the process of writing the contents of an
object to a file and vice versa.............
Read
answer
Latest answer: The transient keyword is used within the
object's member that need not be serialized...............
Read
answer
Latest answer: Class that is nested within a class is called as
inner class. The inner class can access private members of the outer
class................
Read answer
Latest answer: Type 1 - JDBC - ODBC bridge.
Type 2 - Native API partly Java technology enabled driver.............
Read answer
Latest answer: It is the technique which allows a connection
object to be shared by multiple clients, thus improve program
performance................
Read answer
Go
top
Latest answer: Java does not support typedefs, defines, or a
preprocessor. The declaration of named constants is supported in Java through
use of the final keyword................
Read answer
Latest answer: JAR is a Java Archived file which allows many
files to be stored. All applets and classes can be stored in a JAR file thereby
reducing the size...................
Read Answer
Latest answer: Java Native Interface is a framework that allows
the Java code running in the Java Virtual Machine to interact and communicate
with other applications and libraries written in some other
languages................
Read Answer
Latest answer: Serialization is an operation in which an
object’s internal state is converted into a stream of bytes. This stream is
then written to the disk..................
Read Answer
Latest answer: The observer pattern in java is known for its
use in design. Whenever an observable object changes its state, its
corresponding observer classes are notified...................
Read
Answer
Latest answer: A break statement when applied to a loop ends
the statement. A continue statement ends the iteration of the current loop and
returns the control to the loop statement....................
Read Answer
Latest answer: Synchronization does not allow invocation of
this Synchronized method for the same object until the first thread is done
with the object. Synchronization allows having control over the data in the
class...............
Read Answer
Go
top
Latest answer: A monitor works as a lock on the data item. When
a thread holds the monitor for some data item, other threads are locked out and
cannot inspect or modify the data......................
Read Answer
Latest answer: Using the join() method, one can allow one
thread to wait while other to finish.............
Read Answer
Latest answer: Yield method causes the currently executing
thread object to temporarily pause and allow other threads to
execute..................
Read Answer
Latest answer: Sleep holds the threads execution for the
specified time. On the other hand, yield will cause the thread to rejoin the
queue..............
Read
Answer
Latest answer: A scheduler uses the priorities of a task to
determine its execution. Priorities can be high or low determined by the
integer values that are assigned to the tasks................
Read Answer
Latest answer: Yes, we can have.
This is also called as constructor overloading...................
Read Answer
Go
top
More java interview questions with answers
How are Observer and
Observable used?
What is the
difference between preemptive scheduling and time slicing?
What are primitive types in java?
What is ResultSetMetaData?
Explain how to create and use sockets in java.
What is the difference
between static and non-static variables?
What is synchronization and why is it
important? Describe synchronization in respect to multithreading.
What is a task's priority and how is it used
in scheduling?
What is transient variable?
What is the difference between a Vector and
an Array. Discuss the advantages and disadvantages of both?
|