Monday, 13 January 2014

Java Language Interview Question and Answers : 4

Posted by Pritam  |  at  04:52 No comments

16.What is an array?
Array is a group of related data items that share a common name.For instance, we can define an array name salary to represent a set of salaries of a group of employees.
Examples : salary[10]
17.What is a list iterator?
The List and Set collections provide iterators, which are objects that allow going over all the elements of a collection in sequence. The java.util.Iterator interface provides for one-way traversal and java.util.ListIterator is an iterator for lists that allows the programmer to traverse the list in either direction (i.e. forward and or backward) and modify the list during iteration.
18What is the main difference between a String and a StringBuffer class?
String is immutable : you can’t modify a string object but can replace it by creating a new instance. Creating a new instance is rather expensive.

StringBuffer is mutable : use StringBuffer or StringBuilder when you want to modify the contents. StringBuilder was added in Java 5 and it is identical in all respects to StringBuffer except that it is not synchronized,which makes it slightly faster at the cost of not being thread-safe.
19.When to use serialization?
A common use of serialization is to use it to send an object over the network or if the state of an object needs to be persisted to a flat file or a database.
20.What is the main difference between shallow cloning and deep cloning of objects?
Java supports shallow cloning of objects by default when a class implements the java.lang.Cloneable interface.
Deep cloning through serialization is faster to develop and easier to maintain but carries a performance overhead.

<<<PREV                                                                                                  NEXT>>>

About the Author

Write admin description here..

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

Related posts

0 comments:

We Will Appreciate Your Comment As Complement

© 2013 Knowledge To Grab. WP Theme-junkie converted by K-Grab
Blogger templates. Proudly Powered by Blogger.
back to top