Pages

Monday, June 1, 2020

Collection in Java


What is collection:

1. When we want to represent group of an entity into single entity then we should go for collection.

2. It allows us to achieve sorting order, insertion order, remove duplicates, operations based FIFO & LIFO, searching, manipulations, fast retrieving of objects/data, add or remove of objects/data.

3. It mainly consist of List, Set and Queue interfaces which allows us to perform many operations and provides ready made methods for several operations.

4. All the classes and interfaces in "java.util" belongs to Collections
Collection hierarchy
Fig: Collection hierarchy

Monday, May 25, 2020

Exception Handling in Java


What is exception?

Any abnormal condition of a program is called as exception. Handling of such mechanism is called as Exception handling.

Hierarchy of exception is as below:

Hierarchy of exception
Fig: Exception Hierarchy

Tuesday, May 19, 2020

JVM Architecture


JVM is Java Virtual Machine which converts java bytecode (.class file) to native code.

Below figure shows that when the actual working of JVM starts:

Life cycle of Class
Fig.: Life cycle of Class

JVM mainly consist of 3 parts:-

1. Class Loader Subsystem
2. Memory areas
3. Execution engine. 



Wednesday, May 13, 2020

Multithreading in Java

Index:

  1. What is Thread?
  2. Advantages of thread?
  3. How Threads are created in java?  
  4. Difference between Thread class & Runnable interface?
  5. Lifecycle of thread (How thread travels) 


1. What is Thread?


1. Any executable program is called as Thread.

2. Thread is a class in java present in java.lang package

3. Process of executing multiple threads simultaneously is called as MultiThreading.

Consider below example to understanding thread:

MultiProcessing Vs MultiThreading
Example of Multithreading
In above figure, Thread-1 and Thread-2 are executing at a time so it's called as Multithreading.