More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. Collections class is a utility class having static methods for doing operations on objects of classes which implement the Collection interface. For example, Collections has methods for finding the max element in a Collection.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Comparable interface is used for single sequence sorting i.e.sorting the objects based on single data member where as comparator interface is used to sort the object based on multiple data members.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Collections are re-sizable in nature. We can increase or decrease the size as per recruitment.
Collections can hold both homogeneous and heterogeneous data's.
Every collection follows some standard data structures.
Collection provides many useful built in methods for traversing,sorting and search.
Help us improve. Please let us know the company, where you were asked this question :
Q37. Difference between ArrayList and LinkedList ?
Ans. LinkedList and ArrayList are two different implementations of the List interface. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically resizing array.
Help us improve. Please let us know the company, where you were asked this question :
Q44. If we try to add duplicate key to the HashMap, What will happen ?
a. It will throw an exception. b. It won't add the new Element without any exception. c. The new element will replace the existing element. d. Compiler will identify the problem and will throw an error.
Ans. The new element will replace the existing element.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, doesn't provide exclusive access as we cannot allocate and deallocate memory exclusively as Java internally manages it. The advantage of this is that it relieves the coder for such tasks and helps protect from many bugs that may get introduced with imperfect coding. Moreover as java garbage collector collects all unclaimed memory or objects, it helps the application from memory leaks.
On the flip side , as coder doesn't have extensive excess to memory , it is upto java to decide on the state for programming construct and data storage and hence may introduce some security risks. For example - Java keeps string literals in string pool and there is no exclusive way to remove it and hence may stay and sensitive data in string pool may introduce security issues. Moreover when we overwrite a value or object for a variable / reference, it is upto java to purge those values and hence it may stay in memory for a while till java decide that it is no longer referenced and hence should be removed and hence makes it vulnerable for inappropriate access.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  disadvantages of garbage collection  advantages and disadvantages of java memory management  java for security applications  java with sensitive data  memory management
Q47. What is meant by "Vector is synchronized and ArrayList isn't " ?
Ans. It means that only 1 thread can access have access to Vector at a time and no parallel access is allowed whereas Array List allows parallel access by multiple threads.
Help us improve. Please let us know the company, where you were asked this question :
Which of the following methods are used by Java Garbage Collection Mechanism ?
final
finally
finalize
All of the above
Usually asked only to fresh graduates and less experienced developers.
Q53. What is a daemon thread? Give an Example ?
Ans. These are threads that normally run at a low priority and provide a basic service to a program or programs when activity on a machine is reduced. garbage collector thread is daemon thread.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.
Help us improve. Please let us know the company, where you were asked this question :
Ans. The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.
Help us improve. Please let us know the company, where you were asked this question :
Q60. Which of the following syntax are correct ?a. LinkedList<Integer> l=new LinkedList<int>();b. List<Integer> l=new LinkedList<int>();c. LinkedList<Integer> l=new LinkedList<Integer>();d. List<Integer> l = new LinkedList<Integer>();