Java Interview Questions for 2 to 3 years experienced
Being 2 to 3 years of experience in java, you are a beginner in java. Some of the most commonly asked questions in the part are Abstraction, Encapsulation, Polymorphism, Composition and Inheritance. It also includes Collection API, Map,HasMap,List,Set,ArrayList,Vector and HashSet.
Being 2 to 3 years of experience in java, you are a beginner in java. Some of the most commonly asked questions in the part are Abstraction, Encapsulation, Polymorphism, Composition and Inheritance. It also includes Collection API, Map,HasMap,List,Set,ArrayList,Vector and HashSet.
- What is the difference between ArrayList and Vector in java?
The main difference between ArrayList and Vector is, ArrayList is not Synchronized and fast,but Vector is synchronized and slow compared to ArrayList.Both doesn't allow null values.
2.What is the difference between ArrayList and LinkedList in java?
In ArrayList the insertion and deletion is slow since O(n).But the searching is easy O(1). Direct index accessing. But in LinkedList Insertion and deletion is easy, since it uses the node.
LinkedList uses more memory than ArrayList.
3.What is Fail-Fast and Fail-Safe Iterator in java?
On Traversing through a List or Set, if any modification means, adding or removal of any entry will cause ConcurrentModificationException, this is called Fail-Fast and the iterator that allows modification is Fail-Safe. ex:- ListIterator.
4.Difference between throw and throws in java?
The throws operator is normally used along with method part, while the other is inside the method body. To throw a method you must throws it in the method part.
5.What are Checked Exceptions and Unchecked Exceptions?
Exceptions that require the try catch block at compile time are called checked exceptions and the others that are occuring at runtime are called unchecked exceprion.
Checked Exception:- IO Exception.
UnChecked Exception:- ArrayIndexOutOfBound(RunTime).
No comments:
Post a Comment