Checked Vs unchecked Exceptions with example in Java Interview Questions and Answers | Code Decode

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Difference between checked and unchecked exception is very commonly asked java interview questions in every interview
    Udemy Course of Code Decode on Microservice k8s AWS CICD link:
    openinapp.co/u...
    Course Description Video :
    yt.openinapp.c...
    Difference between checked vs unchecked exceptions
    Checked
    Unchecked Exceptions
    Another name
    Checked exceptions are checked by the Java compiler so they are called compile time exceptions.
    Unchecked exceptions are not checked by the compiler. These are called runtime exceptions.
    When
    Checked exceptions occur at compile time.
    Unchecked exceptions occur at runtime.
    Handled by
    These types of exceptions can be handled at the time of compilation.
    These types of exceptions cannot be catched or handled at the time of compilation, because they get generated by the mistakes in the program.
    Handling
    Must be handled in a try-and-catch block, or be thrown by the invoking method
    Exception handling semantics are not required
    Difference between checked vs unchecked exceptions
    Checked
    Unchecked Exceptions
    Force
    Java compiler forces us to handle these exceptions in some manner
    A method is not forced by the compiler to declare the unchecked exceptions into the method declaration.
    Hierarchy
    They are all subclasses of Exception.
    They are all subclasses of RuntimeException.
    Scenario
    Checked Exception represent scenario with higher failure rate
    UnChecked Exception are mostly programming mistakes.
    Throws clause
    The throws clause on a method header must be included for checked exceptions that are not caught and handled in the method.
    The throws clause on a method header is not mandatory
    Checked
    Unchecked Exceptions
    Examples
    File Not Found Exception
    No Such Field Exception
    Interrupted Exception
    No Such Method Exception
    Class Not Found Exception
    No Such Element Exception
    Undeclared Throwable Exception
    Empty Stack Exception
    Arithmetic Exception
    Null Pointer Exception
    Array Index Out of Bounds Exception
    Most Asked Core Java Interview Questions and Answers: • Core Java frequently a...
    Advance Java Interview Questions and Answers: • Advance Java Interview...
    Java 8 Interview Questions and Answers: • Java 8 Interview Quest...
    Hibernate Interview Questions and Answers:
    • Hibernate Interview Qu...
    Spring Boot Interview Questions and Answers:
    • Advance Java Interview...
    Angular Playlist: • Angular Course Introdu...
    SQL Playlist: • SQL Interview Question...
    GIT: • GIT
    Subscriber and Follow Code Decode
    Subscriber Code Decode: www.youtube.co...
    LinkedIn : / codedecodeyoutube
    Instagram: / codedecode25
    #exceptions #java #codedecode

Комментарии • 29

  • @parag4004
    @parag4004 13 дней назад

    How nicely explained. No need to go anywhere now to know what are checked and unchecked exceptions. Thanks. Keep it up

  • @Aniruddhdwivedi
    @Aniruddhdwivedi Год назад +16

    Correct me if I am wrong - All exceptions occur at runtime. The only difference is Java compiler checks probable places in code for checked exceptions and forces developers to handle them.

    • @CodeDecode
      @CodeDecode  Год назад +7

      Correct. Just that we can say they both occur during exception of code. Compile time - conversation of. Java to. Class ( saved in target folder) and. Class to exe is run time. But be very careful while answering this question as this is so much debatable question and trust me most of the interviewers just see what's written on internet and judge you on that. Our suggestion " be diplomatic on this debatable question " 👍👍

  • @ShivaniDiware
    @ShivaniDiware Год назад +3

    Hi Code Decode , I really appreciate your efforts & your content is helping me a lot during interviews recently I have get some interesting questions if possible can you cover those as well?
    1.characteristics of rest web services
    2.what is Richardson Maturity Model?

    • @CodeDecode
      @CodeDecode  Год назад

      Hey Shivani. Thanks Girl 🥰. Sure we will cover them but which company asked these Richard types questions😒. Sad to see such questions😐

    • @ShivaniDiware
      @ShivaniDiware Год назад +1

      @@CodeDecode its asked during internal client interview for American Express

    • @soulfulGirl_
      @soulfulGirl_ Год назад +1

      This Richardson Maturity was asked in epam for me as well ... And can you please made some videos on transaction roll backs please , do we need to roll back only checked exception in transaction?

    • @CodeDecode
      @CodeDecode  Год назад

      We have it Harshini . ruclips.net/p/PLyHJZXNdCXsdPNwIReIMeC_Cr23Szi5tR
      Please do check this

    • @CodeDecode
      @CodeDecode  Год назад +1

      Sure Shivani we will create video on this👍. We didn't know it's been asked intensively 👍👍 thanks Girl 🥰

  • @user-pt5ue6ep9y
    @user-pt5ue6ep9y 11 месяцев назад +1

    Super explanation. Thank you so much

  • @SaeedAhmed-gl3xn
    @SaeedAhmed-gl3xn Год назад +5

    All Exceptions are handled at run time. It is not very much correct to say compile time Exceptions. Instead checked Exceptions are those which occur at run time only but compiler checks if it is handled by the developer or not. Checking is done at compile time for checked exceptions but occurring of Exceptions are always run time only.

    • @CodeDecode
      @CodeDecode  Год назад

      Can you please suggest us some good reliable source of this information. It will be a great help for all of us n our subscribers Saeed 🙏👍👍🙂🙂

    • @CodeDecode
      @CodeDecode  Год назад

      What we found in blogs n papers is : Just that we can say they both occur during excution of code. Compile time - conversation of. Java to. Class ( saved in target folder) and. Class to exe is run time.

    • @shobhitmittal77
      @shobhitmittal77 Год назад

      @@CodeDecode Here it is - ruclips.net/video/V_1IEx15QmE/видео.html&ab_channel=DURGAEDUCATION

  • @Jamie-jz2ti
    @Jamie-jz2ti 3 месяца назад +1

    Thank you Mam 🙏

  • @iron-man-507
    @iron-man-507 Год назад +1

    very helpful video ...thanks

  • @sambayeti1525
    @sambayeti1525 Год назад +2

    Could u please make videos on executor and fork and join framework concepts in multithreading...

  • @yashdeshpande8488
    @yashdeshpande8488 16 дней назад +1

    💯

  • @nikitasarda7389
    @nikitasarda7389 Год назад

    Hi, first of all thank you so much! Can we get notes for all the videos?

  • @yourvoices
    @yourvoices Год назад +1

    Mam please tell me can we create both type of exception in java?

    • @CodeDecode
      @CodeDecode  Год назад

      Yeah you can sandeep

    • @yourvoices
      @yourvoices Год назад

      ​@@CodeDecodebut how can you explain me mam.?

  • @rishiraj2548
    @rishiraj2548 Год назад +1

    🙏👍👍💯💯