Java Interview questions with answers posted on July 22, 2008 at
17:10 pm
Question - What is class loader? Explain the purpose of Bootstrap class loader.
Answer
Class loader finds and loads
the class at runtime. Java class loader can load classes from across network or
from other sources like HTTP, FTP etc.
Bootstrap class loader is responsible
for loading classes that are used by JVM to function properly from
“jdk/jre/lib/rt.jar”.
Question - Explain the difference between traditional java Array and Arraylist
class.
Answer
Traditional java array is fixed length whereas ArrayList supports
dynamic arrays that can grow depending on requirement.
Question - Define TreeSet class.
Answer
TreeSet class is used to store large amount of data and uses tree for storage.
Items are stored in ascending order. TreeSet sorts all data properly even if
data are entered in a unsorted manner.
Question - String object is immutable, Explain.
Answer
This means once you have created String object and assigned a value, you can’t
change the value of the object. If you try to change the value, a new object is
created and previous one still there in the memory.
Question - What is StringBuffer class?
Answer
StringBuffer class is same as String class with the exception that it is
mutable. It allows change and doesn’t create a new instance on change of
value.
Question - Explain the difference between pass by value and pass by
reference.
Answer
In pass by value, a copy of variable is passed to the method; the values of the
variable can’t be changed in the method.
In pass by reference, a pointer of the variable is passed and the values can be
modified in the method.
Question - Explain access modifiers in JAVA.
Answer
Java provides four access modifiers
Public – The member with public modifier can be access by any other class.
Protected – The member with protected modifier can be accessed by the derived
class only.
Private – The member with Private modifier can be accessed within the class.
Default – Default represents Private access in JAVA.
Question - What is serialization?
Answer
It is the process of converting object instance into stream of bytes.
This conversion is required when objects have to be sent over network.
Question - Define Savepoints in a transaction.
Answer
Using Savepoint, you can mark one or more places in a transaction and you can
perform rollback to one of those savepoint at any point of time during
transaction process.
Question - What are filter class in java?
Answer
The filter class in java can manipulate request before reaches to the
web server. It can also manipulate response before it reaches the client
browser.
Question - How do we consume a web service in java?
Answer
Client can consume web services in java in 3 ways.
Using stub
Using DLL
Using dynamic proxies. |