1.
Synchronization in Java
Since java is a multithreaded language , multiple threads run concurrently to complete a program. So
synchronization is required in order to avoid any error in accessing of the shared resources. Java
synchronized code will only be executed by one thread at a time. In Summary, Java
synchronized Keyword provides this functionality of locking and unlocking the objects
2. Difference between arraylist and vector
Arraylist is not synchronized and it is fast.
Since Array is an index based data-structure searching or getting element from Array with index is pretty
fast. Array provides O(1) performance for get(index) method but remove is costly in ArrayList as you need to
rearrange all elements. On the Other hand LinkedList doesn't provide Random or index based access and
you need to iterate over linked list to retrieve any element which is of order O(n).
3. Difference between Throws and Throw
Throws is the declaration of exception thrown by the method and Throw is actually throwing the exception.
4. What is difference between checked and unchecked Exception in Java.
checked Exception requires mandatory exception handling code while unchecked doesn't.
5. What is Static
Static variable and Methods can be used without having any instance of the Class. Only the
Class is required to invoke a static Method or static variable.