Monday 2 April 2018

Java Exception Handling Full Guide In Hindi ~ Search How

Welcome To Tips Arena


Java Exception Handling Full Guide In Hindi

Hello dosto humne apni peechli post main seekha tha Java Inheritance ke bare main or ab hum seekhenge Java Exception Handling ke bare main to aayiye ab hum chalte hain seedhe apne topic par.


Java Exception Handling Full Guide In Hindi ~ tips arena


Java Exception Handling Introduction In Hindi

Friends Exception run time errors hoti hain. ye ek aisi situation hoti hain jo humare run hote huye programme ko bhi stop kar deti hain. for example jitni memory humare programme ko execute hone ke liye chahiye utni memory humare computer main agar nahi hai to humare program ka execution stop ho jayega. dosto ye out of memory execution hai. dosto aisi hi situation ko hum exceptions kehte hain.

Dosto jis trah hum program banate time kisi statement ke aage semicolon lagana bhool jate hain to vo program error message display kar deta hai or fir vo compile bhi nahi hota hai dosto thik usi trah exception generate hone par humara program stop ho jata hai or execute nahi hota hai.

Friends agar hum chahte hain ki humara program exception aane par stop na ho or execute hota rahe to dosto uske liye hume exceptions ko handle karna hoga. dosto ise hi exception handling kehte hain. dosto jab hum exceptions ko handle karte hain to humara program exception aane par stop nhi hota balki exception wale code ko skip karke baki ko execute karta hai.



Exception Handling Keywords In Hindi

Friends java main hum kuch keywords ki help se exceptions ko handle karte hain. dosto ye sabhi keywords milkar jo structure banate hain jo implement karne main bahut hi aasan hota hai. dosto in sare keywords ke bare main ab hum vistar se padhenge.

Keywords
Explanation
Try
Humare program ka vo code jo exception generate kar sakte hai, use hum try block main likhte hai for example hum program main koi mathematical operation kar rahe hain or hume pta lagta hai ki exception generate ho sakti hai to hum code ko try block main likhte hain.      
catch 
Agar try block main koi exception generate hoti hai to vo isi block main handle ki jati hai. Hum is block main vo code likhate hain jo exception aane par hum execute karna chahte hain for example hum ek message print karwa sakte hain jo user ko bataye ki exception generate huyi hai.      
throw 
Jadatar exceptions humare liye pehle se hi java library main define hai or ye exception java automatically throw kar deti hain. Lekin dosto agar hum chahte hain to khud ki exceptions bhi create kar sakte hain. Aisi expressions ko hume khud hi throw karna hota hai iske liye hum throw keyword use karte hain. Hum chahe to predefined exception bhi throw kar sakte hain.       
Throws
Hum nested try blocks use kar sakte hain. Agar hum chahte hain ki kisi exception ko outer try block handle kare to aisi situation main hum throws keyword use karte hain. hum method main definition ke aage throws keyword lga kar sabhi exceptions ke name likh dete hain. Dosto aisa karne se agar koi exception aati hai to outer try block use handle karta hai.  
Finally
Exception handle karne ke baad hum jo code execute karwana chahte hain use finally block main likhte hain. Try block main exception aane ke baad compiler us code ko execute nhi karta hai or catch block ke baad seedha finally block ko execute karta hai.  



Handle Exceptions Steps In Hindi

  • Friends sabse pehle hum us code ko try block main likhna hai jisse exception generate ho sakti hai.

  • Dosto Try block ke baad catch block main exception ko handle karne ke liye code likhna hai. dosto jese hi hum exception se related koi message print karwa sakte hain. 

  • Friends Exception handle karne ke baad hum jo execute karwana chahte hain use finally block main likhana hai.



Some Common Exceptions In Hindi

Friends Exceptions ko handle karne se pehle exceptions ke bare main jaanna humare liye kafi jaruri hai. dosto kuch exceptions aisi hoti hain jo java main regularly aati hai. dosto in common exceptions par hum aasani se practice kar sakte hain or apni skill ko improve kar sakte hain. dosto java me regularly aane wali kuch common exceptions ke bare main hum vistar se seekhenge.

Arithmetic Exceptions

Friends koi bhi arithmetic error jese ki agar hum kisi number ko zero se divide karne ki koshish kare ya fir kisi variable main uski size se jada value store karne ki koshish kare to Arithmetic-Exception generate hoti hai.

Class Cast Exception

Dosto agar hum kisi class ka reference dusri class main store karwana chahte hain or agar humari pehli class dusri class ki sub class nhi hoti hai to Class-Cast-Exception generate hoti hai.

Array Store Exception

Agar Humne string array banaya hai or usme hum string store karne ki koshish karte hain to Array-Store-Exception generate hoti hai.

Array Index out of Bounds Exception

Agar humare array ki size 5 hai or hum 6th position par value store karne ki koshish kare ya 6th position ko access karne ki koshish kare to Array-Index-Out-Of-Bounds-Exception generate hoti hai.

Illegal Argument Exception

Friends jab hum kisi method main invalid argument pass karte hain jese ki int ki jgah string pass kar de to Illegal-Argument-Exception generate hoti hai.

Null Pointer Exception

Friends Java main hum kisi reference variable ko null value assign kar sakte hain lekin agar hum is reference variable ko use karne ka prayas karte hain to NullPointerExcetion generate hoti hai.

Number Format Exception

Friends jab hum kisi string value ko number main cast karne ki kosish karte hain to Number-Format-Exception aati hai.



Example

Import java.lang.*;

class
{
  public static void main(String args[])
  {
      int num = 120;
      int a = 0;
   
       try
       {
            num = num / a;
         
           System.out.println(num);
     }

    catch(ArithmeticException e)
    {
           System.out.println(“You can not divide a number by zero”);
    }
 }
}




Final Words

To dosto ye thi humari aaj ki post hum ummid karte hain ki aapko humari aaj ki ye post pasand aayi hogi agar aapko post se related koi bhi jankari chahiye ya aap koi suggestion dena chahte hai to aap hume comment karke bta sakte hain or dosto post ko share karna na bhoole. Thanks..



Please Share This Post

Team Tips Arena

No comments:

Post a Comment