Posts

Showing posts from May, 2025

Unit-5 : Collections

Image
  ArrayList  supports dynamic arrays that can grow or shrink as needed. The ArrayList class implements the List interface. Can contain duplicate elements. Maintains insertion order. Non synchronized. Manipulation is slow . LinkedList class uses a doubly linked list to store the elements. It  implements the List interface. Can contain duplicate elements. Maintains insertion order. Non synchronized. Manipulation is fast HashSet  class is used to create a collection that uses a hash table for storage. It  implements the Set interface. Contains unique elements only. Allows null value. Non synchronized. HashSet doesn't maintain the insertion order. HashSet is the best for search operations TreeSet  class implements the Set interface that uses a tree for storage. Contains unique elements only like HashSet. Access and retrieval times are quiet fast. Doesn't allow null element. Non synchronized. Maintains ascending order.   // 6 methods from collection/ ArrayL...

Unit-4 : Multi Threading

Image
  Thread Life Cycle The life cycle of a thread in Java is controlled by JVM. During the execution of thread, it is in any of the following five states. Hence Java thread life cycle is defined in five states.   i. New :  The thread is in new state when the instance of thread class is created but before the calling of start() method. ii. Runnable : The thread is in runnable state after the invocation start() method, but the thread scheduler has not selected it to be the running thread. Any number of threads exists in this state. iii. Running : The thread is in running state when the thread scheduler selects a thread for execution. iv.  Waiting/blocked/sleeping : this is the state when the thread is still alive but is not eligible currently to run. v. Terminated : A thread is in terminated or dead state when its run() method exits.     II)Explain any 6 methods of Thread class:  1.  public void start():   starts the execution of the thread. start...