image source in Google search |
This post totally I am concentrate
on mostly frequently asked question on core java. Most of the java peoples know
these kind of question but how you’re presented at time of interview our goal is
to tell you strongly at presence of interview. I think your all very much
strong please see and tell me your faced interview also thanks for advanced
thanks every one. Now see the following interview question.
Q) What are
the difference between Overloading and Overriding in Java?
R)
Property
|
Overloading
|
Overriding
|
1) Method names
|
Same
|
Same
|
2) Arguments
|
Different(at least
order)
|
Same(including order)
|
3) signature
|
Different
|
Same
|
4) return type
|
No rule or no
restriction
|
Must be same until 1.4
version. But from 1.5
version onwards co-variant return types are allowed
|
5) throws clause
|
No restrictions
|
The size of the checked
exception should not be
increased. But no restrictions for unchecked
exceptions.
|
6) Access Modifier
|
No restrictions
|
Should be decreased
|
7) Private/final/static
|
Can’t be overloaded
|
Can’t be overridden
|
8) Method resolution
|
Method resolution takes care by compiler based on
reference type and
arguments
|
Takes care by JVM based on runtime object
|
9) Other names
|
Compile time (or) static
polymorphism (or) early binding
|
Runtime (or) dynamic
polymorphism (or) late
binding
|
Q) What is the difference between StringBuffer and String
Builder in Java?
R)
StringBuffer
|
String Builder
|
1.All methods are
Synchronized
|
1. No method is
synchronized
|
2. StringBuffer is
thread safe
|
2. StringBuilder is not
thread safe
|
3. Performance is very
low
|
3. Performance is high
|
4. Available from 1.0
version
|
4. Available only in 1.5
version
|
Q) What is the difference between == and .equals() ?
R)
==
|
.equals()
|
1) It is an operator and applicable for
both primitive and
Object references.
|
1) It is a method applicable for Only
Object reference.
|
2) For Object reference r1, r2 r1 ==
r2 is true iff both r1 and r2 pointing
to the same object on the heap i.e it is
meant for reference comparison.
|
2) Default implementation available in
Object class is meant for reference
comparison only i.e
r1.equals(r2) is true iff both r1,r2 are pointing to the same object on the
heap.
|
3) We can’t override ==
operator.
|
3) We can override equals() for content
comparison.
|
4) IF r1 & r2 are incompatible then
r1 == r2 results Compile
Time Error.
|
4) If r1 & r2 are incompatible then
r1.equals(r2) is always
false.
|
5) For any Object reference r, r ==
null returns false.
|
5) For any Object reference r,
r.equals(null) returns
false.
|
Q) What is
the difference between all cursors in Collection Frame work?
R)
Properties
|
Enumeration
|
Iterator
|
ListIterator
|
1) It is Legacy?
|
Yes
|
No
|
No
|
2) It is applicable
|
Only for legacy classes
|
For any collection
|
Only for list
implemented classes
|
3) How to get?
|
By using elements()
|
By Using iterator()
|
By using listIterator()
|
4) Accessibility
|
Only read
|
read & remove
|
read/remove/replace/add
|
5) Movement
|
Single direction
(Only Forward)
|
Single direction
(Only Forward)
|
Biderctional
|
6) Methods
|
hasMoreElements()
nextElements()
|
hasNext()
next()
remove()
|
hasNext()
hasPrevious()
.
|
7) version
|
1.0
|
1.2
|
1.2
|
Post a Comment
very nice plz past one example so that we can learn easily thx
for updating
Post a Comment