Saturday, May 10, 2008

Java Interview Questions 45

221. What is a cloneable interface and how many methods does it contain?- It is
not having any method because it is a TAGGED or MARKER interface.

222. What is the difference between abstract class and interface?- a) All the
methods declared inside an interface are abstract whereas abstract class must have
at least one abstract method and others may be concrete or abstract. b) In abstract
class, key word abstract must be used for the methods whereas interface we need not
use that keyword for the methods. c) Abstract class must have subclasses whereas
interface can’t have subclasses.

223. Can you have an inner class inside a method and what variables can you
access?- Yes, we can have an inner class inside a method and final variables can be
accessed.

224. What is the difference between String and String Buffer?- a) String objects
are constants and immutable whereas StringBuffer objects are not. b) String class
supports constant strings whereas StringBuffer class supports growable and
modifiable strings.

225. What is the difference between Array and vector?- Array is a set of related
data type and static whereas vector is a growable array of objects and dynamic.

No comments:

Useful Information