Exception Handling Interview questions and answers in Java | Part -1 | Code Decode

Поділитися
Вставка
  • Опубліковано 13 вер 2020
  • In this video of code decode we have covered all important Exception Handling Interview questions in Java for freshers and experienced
    Udemy Course of Code Decode on Microservice k8s AWS CICD link:
    openinapp.co/udemycourse
    Course Description Video :
    yt.openinapp.co/dmjvd
    Exception Handling part 2 : • Exception handling Int...
    Q) What is an exception?
    The exception is an abnormal condition that occurs during the execution of a program and disrupts the normal flow of the program. If not handled properly it can cause the program to terminate abruptly.
    Q) How do we handle exceptions in Java
    Try
    Encloses set of statements which can throw exception hence are required to be monitored.
    Catch
    When exception occur, this block catches that exception and work accordingly to handle it or to throw it as required.
    Finally
    This block gets executed always regardless of exception occurrence. Hence clean up is done here.
    Q) Difference between Exception VS Error
    Exception
    We can recover from exception using try catch block or using throw
    Compiler will have knowledge about checked Exceptions hence Compiler will force you to use try-catch blocks
    Exceptions are related to application
    Exceptions include both checked as well as unchecked type.
    Exceptions in java are of type java.lang.Exception.
    Error
    Recovering from Error is not possible
    Compiler will not have any knowledge about unchecked exceptions and Errors
    Errors are related to environment where application is running
    All errors in java are unchecked type
    Errors in java are of type java.lang.Error.
    Q) Can we write only try block without catch and finally blocks?
    No. either catch or finally is must.
    if no then what error will come?
    Answer : compile time error saying “insert finally to complete try statement” like this:
    Q) Can we write any other statements between try catch or finally block?
    No. Try must be followed directly by either catch or finally.
    Q) Does remaining statements in try block executes after exception occurs.
    No. if exception occurs at a particular point in try block then all statements after that statement where exception is occurred will not be execute and the flow goes directly to either catch block if there is any or else program terminates. Hence we need finally block to do all clean up like closing files or removing locks.
    Q) What Is the Difference Between Throw and Throws Keywords in Exception Handling in java?.
    Throw
    Java throw keyword is used to explicitly throw an exception.
    Checked exception cannot be propagated using throw only.
    Throw is used within the method.
    You cannot throw multiple exceptions.
    Throws
    Java throws keyword is used to
    declare an exception.
    Checked exception can be propagated with throws.
    Throws is used with the method signature.
    You can declare multiple exceptions.
    Q) What Happens When an Exception Is Thrown by the Main Method?
    When an exception is thrown by main() method, Java Runtime terminates the program and prints the exception message and the stack trace in-system console.
    Q) What do you understand by unreachable catch block error.
    This error comes when you keep super classes first and sub classes later. Like here We kept Exception which is parent of NullPointer Exception first.
    Hence the order of catch blocks must be from most specific to most general ones.
    -------------------------------------------------------------------------------------------------------------------------------------
    Code Decode Playlists
    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...
    GIT : • GIT
    -------------------------------------------------------------------------------------------------------------------------------------
    Subscriber and Follow Code Decode
    Subscriber Code Decode : ua-cam.com/users/CodeDecode?...
    Linkedin : / codedecodeyoutube
    Instagram : / codedecode25
    --------------------------------------------------------------------------------------------------------------------------------------
    #ExceptionHandlingInterviewQuestionsInJava
    #ExceptionHandlingHandlingInterviewQuestionsForExperiencedInJava
    #javainterviewquestionsandanswers #codedecode

КОМЕНТАРІ • 270

  • @kanchanyasita8272
    @kanchanyasita8272 3 роки тому +6

    Java 7 and beyond, try with resources allows to skip writing the catch as well as finally and closes all the resources being used in try-block itself.
    Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource.
    See this code example
    static String readFirstLineFromFile(String path) throws IOException {
    try (BufferedReader br = new BufferedReader(new FileReader(path))) {
    return br.readLine();
    }
    }

  • @prisha1729
    @prisha1729 3 роки тому +6

    Please upload videos on advance exception handling and try with reassures as well. Your videos are great for interview preps. Thanks

  • @mohantyfamily1521
    @mohantyfamily1521 2 роки тому +4

    Many thanks for making such wonderful videos and this really help people to Crack an interview. Please make videos on exception handing with real time scenarios along with garbage collector.

    • @CodeDecode
      @CodeDecode  2 роки тому

      Sure, nice topic. We will create videos on that too soon 👍👍

  • @aasimahsan6167
    @aasimahsan6167 10 місяців тому +4

    great explanation cleared all the doubt and also gained confidence

  • @sandhyarajkumar8597
    @sandhyarajkumar8597 2 роки тому +3

    Your explanation is amazing...to the point...understandable...keep making such videos...😊

    • @CodeDecode
      @CodeDecode  2 роки тому

      Thanks a lot Sandhya 🙂👍

  • @prikansiyadav436
    @prikansiyadav436 3 роки тому +2

    Your explanation is really very helpful ❤️
    Thank you so much

  • @hansirawat9322
    @hansirawat9322 3 роки тому +2

    Thanks for sharing.

  • @rishikachowdarypotturu3488
    @rishikachowdarypotturu3488 3 роки тому +5

    Great content...Upto the point.... Looking for many more to come on the channel 👏

    • @CodeDecode
      @CodeDecode  3 роки тому

      Thanks Rishika for the nice words....

  • @vibhorgoel4614
    @vibhorgoel4614 3 роки тому +1

    Outstanding work done... Watching all your videos for learning. Expecting more soon.. Good Job

  • @aayushiagarwal3663
    @aayushiagarwal3663 3 роки тому +1

    Thank you for such good videos.
    I have watched your other java videos which came out useful for me

    • @CodeDecode
      @CodeDecode  3 роки тому

      Thanks for the nice words 👍

  • @shubhamtagalpallewar7125
    @shubhamtagalpallewar7125 3 роки тому +2

    Thank you ma'am, was waiting for this video...

  • @mnishi2780
    @mnishi2780 3 роки тому +1

    Great content...They r really helpful...Concept is very clear...U r sharing ur knowledge with us...It is appreciable madam...Thanks alot ...pls upload advanced exception handling interview questions

    • @CodeDecode
      @CodeDecode  3 роки тому

      Sure Nishi, we will upload them soon 👍🙃

  • @vishalcoder4964
    @vishalcoder4964 3 роки тому +1

    Helps a lot. Thank you @Code Decode

  • @divsreviews2860
    @divsreviews2860 Рік тому +5

    Hello Mam, You made Java Developer's life easy,, Thank you so much for your dedication towards Java Developer ✌️🙏🏻.. God Bless you 😊

  • @raghurambodapati6769
    @raghurambodapati6769 3 роки тому +3

    Hi, your interview questions are very good and helpful, I want you to make an video on Generics concept and also on Java 8 feature interview questions

    • @CodeDecode
      @CodeDecode  3 роки тому

      sure in next video i will capture java 8 interview questions

  • @luckyyadav5540
    @luckyyadav5540 3 роки тому +1

    very nice Discuss

  • @praveenraj3721
    @praveenraj3721 3 роки тому +1

    this video is very helpful and as you said you need to extend this video to intermediate and advanced level.

  • @sukunkusum1720
    @sukunkusum1720 2 роки тому +3

    Hi Team CodeDecode! hope you are fine. excellent video as usual. Please make a video on try with resources and exception chaining!

    • @CodeDecode
      @CodeDecode  2 роки тому

      Sure Sukun, we will do that soon 👍🙂

  • @chenchaiahmalli6234
    @chenchaiahmalli6234 3 роки тому +1

    Very nice and clear explanation Mam...Its very helpful...Keep it up.

  • @aaaaaaaa3811
    @aaaaaaaa3811 3 роки тому +1

    very nice and awesone explanation.👌👌👌....keep doing more n more videos like this mam.....hatsoff to u...

  • @shamukakhamari4661
    @shamukakhamari4661 3 роки тому +3

    Please make videos on thread interview questions . your explanations are really amazing.👍

    • @CodeDecode
      @CodeDecode  3 роки тому

      Thanks Shamuka 👍. Sure will create a video on multithreading

  • @Hare_Krishna143
    @Hare_Krishna143 2 роки тому +2

    Such helpful content!!! Appreciate

    • @CodeDecode
      @CodeDecode  2 роки тому +1

      Thanks for the nice words Manoj

  • @ravirajsaraganachari3038
    @ravirajsaraganachari3038 3 роки тому +1

    Content is so valuable, Tq 🤗

  • @muchukundareddy5315
    @muchukundareddy5315 2 роки тому +1

    Could you please tell me in which scenario we will create customized checked exception and in which scenario we will create customized unchecked exception?

  • @priyapandian8655
    @priyapandian8655 3 роки тому +1

    Very useful and I like to get some advanced question in exception also

    • @CodeDecode
      @CodeDecode  3 роки тому

      Sure will make part 2 soon

  • @arlynsneha5052
    @arlynsneha5052 3 роки тому +2

    Wonderful video mam 🤩🤩🤩🤩🤩. Mam plz do intermediate exception handling questions
    too.

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      Sure Sneha, we will do that👍👍

  • @AjeetSingh-hs2ec
    @AjeetSingh-hs2ec Рік тому

    Hello, Can we use multi catch block in Java 8 and above also. Thanks in advance

  • @hemashilpa3954
    @hemashilpa3954 2 роки тому +1

    Great content..please upload advanced level exception handling interview questions

  • @nirmalvaidhyanathanr1299
    @nirmalvaidhyanathanr1299 3 роки тому +1

    Explanation is very good and please upload advanced exception handling questions

  • @sureshgarine
    @sureshgarine 3 роки тому +1

    thank you madam, please continue advanced questions on exception handling

  • @rahulnigam7529
    @rahulnigam7529 2 роки тому +3

    @10.36 - question must prepare , its always ask in interview . Nice video

    • @CodeDecode
      @CodeDecode  2 роки тому

      Yes it is. Nice observation Rahul 👏👏👏👏👏

  • @reddaboinavasista4166
    @reddaboinavasista4166 7 місяців тому +1

    Very Underrated youtuber. Deserves more subscribers.

  • @solankijigar11
    @solankijigar11 3 роки тому +1

    Great job, thanks!!!!!

  • @dystopianNinja1289
    @dystopianNinja1289 3 роки тому +5

    Thanks for all of these videos

  • @prithvisingh40
    @prithvisingh40 3 роки тому +2

    Advanced exception handling will be helpful

  • @PinakGanguly12rocks
    @PinakGanguly12rocks 2 роки тому +1

    Thanks for such a great video.Request you to also make a intermediate level Exception handling interview video content.

    • @CodeDecode
      @CodeDecode  2 роки тому

      sure we will create video on it soon

  • @BhushanRawoolShridhar
    @BhushanRawoolShridhar 3 роки тому +1

    You are really doing a great job

  • @abhijeetw693
    @abhijeetw693 Рік тому +1

    Yes,plz create video on try with resource

  • @bharukatta
    @bharukatta 2 роки тому +1

    Superb.Thank uu

  • @ayushman_19
    @ayushman_19 Рік тому +2

    Please continue this exception handling series

  • @parthec1
    @parthec1 2 роки тому +1

    thanks for informative video,,

  • @sankarasubramanian568
    @sankarasubramanian568 Рік тому +1

    good content, thanks !

  • @rudrarajusowmya8943
    @rudrarajusowmya8943 2 роки тому +7

    Firstly thanks for this tutorial. Can you cover the Intermediate and Advance level of questions also. It will be helpful

    • @CodeDecode
      @CodeDecode  2 роки тому +1

      Sure Sowmya, we will do that👍👍

    • @nehaladva256
      @nehaladva256 2 роки тому

      please provide video link for Intermediate and Advance level of questions

  • @vinothkumarg7731
    @vinothkumarg7731 3 роки тому +2

    Very useful Pls upload more on that

  • @kalpeshmahagaonkar2145
    @kalpeshmahagaonkar2145 3 роки тому +7

    All the interview questions are very helpful. Please cover the Intermediate and Advance level of questions also. I have watched all your videos. Your efforts are highly appreciate.

    • @CodeDecode
      @CodeDecode  3 роки тому

      Thanks Kalpesh. It means a lot 🙏👍

  • @fionamiriamabraham5074
    @fionamiriamabraham5074 3 роки тому

    Hi ,thank you for the useful videos. Can you please do videos on multi threading and web services also

    • @CodeDecode
      @CodeDecode  3 роки тому

      Sure will upload them soon

  • @lavsharma3441
    @lavsharma3441 2 роки тому +1

    Nice and easy explanation Thanks ma'am

  • @shankarpatilsp
    @shankarpatilsp 3 роки тому +1

    Thank You so much Ma'am..!!

  • @kazaasekhar
    @kazaasekhar 2 роки тому +1

    thank you very good explaination

  • @saisybase
    @saisybase 3 роки тому +1

    Thank you very much

  • @technicalfarmer4462
    @technicalfarmer4462 3 роки тому +1

    Explained very nicely

  • @sushmakolli1119
    @sushmakolli1119 3 роки тому +1

    Please make exception handling part 2 video with advanced concepts like Exception chaining,try with multiple resources.

    • @CodeDecode
      @CodeDecode  3 роки тому

      Sure Shushma 🙂🙂👍👍

  • @sukanyasundar4302
    @sukanyasundar4302 3 роки тому +1

    Thanks a lot for all the interview related videos. Appreciate your time and effort.

  • @AvinashKumar-ps8wl
    @AvinashKumar-ps8wl 3 роки тому +1

    Please , upload exception handling advanced and intermdiate level questions with "Exception handling in spring boot applications " . This is mostly asked question in the interviews .

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      Yes I m planning to upload this soon. Thanks for the topic. 👍

  • @rampatil1261
    @rampatil1261 2 роки тому +1

    Thanks you so much for this video
    Please make Advance questions also

    • @CodeDecode
      @CodeDecode  2 роки тому

      sure ram we will make it soon

    • @rampatil1261
      @rampatil1261 2 роки тому

      @@CodeDecode thanks in advance 😃

  • @ma8969
    @ma8969 2 роки тому +1

    Thank you so much

  • @azimrahman3584
    @azimrahman3584 3 роки тому +8

    More interview questions of exception handling upload it

  • @akadas6124
    @akadas6124 3 роки тому +1

    Please make video on intermediate and advance exception handling also.. this was really good🙂

  • @ankitanayak6485
    @ankitanayak6485 3 роки тому +2

    The way of ur explanation 🙌🙌1st time i will see ur video nd so satisfied..tysm 🙏 please upload multi threading concept 🙏

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      Sure I will upload a video for multi threading soon 👍👍👍👍

    • @ankitanayak6485
      @ankitanayak6485 3 роки тому +1

      @@CodeDecode tysm☺️🙌

  • @allancmm
    @allancmm 2 роки тому

    Since Java 8, it's possible to use try whitout expliciting using catch. When creating object from classes that implement AutoCloseable:
    try (FileReader fr = new FileReader(path); BufferedReader br = new BufferedReader(fr)) {
    return br.readLine();
    }

    • @anushrutimohanty6113
      @anushrutimohanty6113 6 місяців тому

      Thanks @allancmm for this information. This is very helful !

  • @koushikratnagiri903
    @koushikratnagiri903 2 роки тому +1

    Please cover the intermediate and advanced also

  • @ravirajsaraganachari3038
    @ravirajsaraganachari3038 3 роки тому +3

    Please make next set of FAQ on exception.

  • @nehagirase2656
    @nehagirase2656 3 роки тому +2

    Hello mam, thank you this video so helpful mam but can you make experience level exception handling questions

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      Sure. I will soon create advance level interview questions for this topic

  • @keerthu7055
    @keerthu7055 Рік тому +1

    Great mam

  • @bharatahirwar2252
    @bharatahirwar2252 3 роки тому +1

    at the end ,you mentioned finally is key word , and finalize is a block , which is wrong statements,
    Except this you explained nicely,
    Awesome explanation.
    pls try to cover all topics for interview perspective.

    • @dileepnb01
      @dileepnb01 2 роки тому

      Final is a keyword
      Finally is a block
      Finalize is a method
      Is it correct now?

    • @vishalkadam7728
      @vishalkadam7728 Рік тому

      14.20 timestamp ...checked exception can be propagated using throw

  • @user-pf9jq7ys3m
    @user-pf9jq7ys3m Рік тому +1

    love u madam tq gave much info😍

  • @rajashekarj3313
    @rajashekarj3313 2 роки тому +1

    Wonderful 🙏😍

  • @EncryptoG
    @EncryptoG 3 роки тому +2

    Please upload interview questions of exception handling, Thank you.

    • @CodeDecode
      @CodeDecode  3 роки тому +2

      Sure will upload soon 👍

    • @GauravKawatrakir
      @GauravKawatrakir 3 роки тому +1

      @@CodeDecode waiting for other set questions mam, please upload.

  • @heenakouser7733
    @heenakouser7733 2 роки тому +1

    Thank you so much maam

  • @sonalgupta7083
    @sonalgupta7083 Рік тому

    Can you please upload video of java best practices

  • @sachinjadhav8759
    @sachinjadhav8759 2 роки тому +1

    thank you

  • @sougatabanerjee8832
    @sougatabanerjee8832 Рік тому +23

    Finalize is not a block it is a method of Object class.and another info I found it's depricated from Java 9.correct me if I wrong. Great Video thanks.

    • @ig_haxie
      @ig_haxie Рік тому +2

      a method is also called as a "block" of code

    • @divsreviews2860
      @divsreviews2860 Рік тому

      Yes Finalize got deprecated from JDK 9, I read in Java Complete reference 10 book

    • @Foodmoods_s
      @Foodmoods_s 10 місяців тому

      That method is "Finalized" which is used before the garbage collection, "Finally" is a keyword and a block also which will always execute except when we use the system.exit or in jvm crash abruptly..in these two situations "finally" block will not executed..

  • @yoshitamahajan353
    @yoshitamahajan353 3 роки тому +1

    Thank u so much..

  • @philipdodson7870
    @philipdodson7870 3 роки тому +1

    Great video, my only feedback is that to say final variable cannot be changed is misleading as final variables can still be mutated

    • @CodeDecode
      @CodeDecode  3 роки тому

      Thanks. Ohh but Except inside constructor, how can we change/ instantiate it's value?

  • @maheshakkemwar509
    @maheshakkemwar509 3 роки тому +1

    Thank you 3000 😊

  • @suganyasums685
    @suganyasums685 2 роки тому +1

    Please make video of advanced exception handling like chaining etc..

    • @CodeDecode
      @CodeDecode  2 роки тому

      Sure Suganya. We will upload it in next few days for sure 🙂👍

  • @abiultimate
    @abiultimate 2 роки тому +1

    Superb

  • @ankitabagde6421
    @ankitabagde6421 3 роки тому +1

    Thanks for the vedio it very helpful. Can you please create the same for custom exception?

  • @manoharsitaram3300
    @manoharsitaram3300 3 роки тому +1

    I think from java 1.7 onwards we can provide only try block also. Or may be it is possible when we are using try with resource . Can you please confirm that by looking into it once.

    • @CodeDecode
      @CodeDecode  3 роки тому

      That's with try with resources. As said in the video I Will cover that in part 2

  • @prateetisingha6729
    @prateetisingha6729 3 роки тому +1

    Please upload more questions of exception handling.

  • @nandiniverma6127
    @nandiniverma6127 3 роки тому +1

    ❤️ helpful

  • @mohitgharate8171
    @mohitgharate8171 3 роки тому +1

    Please upload videos on advance exception handling and try with resources

  • @nandasagar3973
    @nandasagar3973 2 роки тому +1

    thank u

  • @avneeshsaxena2260
    @avneeshsaxena2260 3 роки тому +2

    Plz do make video for multithreding real time senario based interview question.
    I have searched on entire UA-cam but did not get single video which is good.
    They have asked like where do you use multithreding in your web project...?

    • @CodeDecode
      @CodeDecode  3 роки тому

      That's very nice topic that you have suggested. I will surely make a video on this.

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      If possible can you please share what all kind of questions you have faced that you want me to cover.

    • @yoshitamahajan353
      @yoshitamahajan353 3 роки тому

      @@CodeDecode where have u used multithreading in your project is one the question

  • @prashantmehra5247
    @prashantmehra5247 3 роки тому +1

    Thank you ma'am

  • @farhansheikh1278
    @farhansheikh1278 4 місяці тому

    Can you also create a interview questions on File Handling? Thanks☺

  • @josephkumar8259
    @josephkumar8259 3 роки тому +1

    Thank you for the video. Can we handle all the exceptions with the parent class Exception...??

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      Yes you can but it's not a good practice.

    • @josephkumar8259
      @josephkumar8259 3 роки тому +1

      @@CodeDecode Ok. Thank you.

  • @priyanka0112
    @priyanka0112 3 роки тому +2

    create more video on exception handling,multithreading and collection questions.

    • @CodeDecode
      @CodeDecode  3 роки тому

      sure Priyanka we will create one soon....

    • @sonalibajpai8323
      @sonalibajpai8323 3 роки тому

      😍😭😭❤️😭❤️💞💞😒💞💞💞💞💞💞💞💞💞😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢💋😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢@@CodeDecode in in in

    • @sonalibajpai8323
      @sonalibajpai8323 3 роки тому

      Iio iiii you can

    • @sonalibajpai8323
      @sonalibajpai8323 3 роки тому

      @@CodeDecode in in thatioiiii

  • @aaaaaaaa3811
    @aaaaaaaa3811 3 роки тому +1

    1. How u have handled expections in u r project?
    please give a brief explanation on this mam....asked many times in several interviews...

    • @CodeDecode
      @CodeDecode  3 роки тому

      Will try to put next video on exception handling with spring.

  • @NSreenivasulu-d2p
    @NSreenivasulu-d2p 21 день тому

    Upload intermediate and advanced level questions... maam.

  • @SunilKumar-on1iq
    @SunilKumar-on1iq 3 роки тому +1

    👏👏👏👏👏👏👏

  • @revansiddappapanchal2068
    @revansiddappapanchal2068 Рік тому +1

    your voice is awesome

  • @priyankaraut9289
    @priyankaraut9289 3 роки тому +1

    Can u please upload interview questions on rest Webservices and spring n springboot

    • @CodeDecode
      @CodeDecode  3 роки тому

      Sure. Next spring boot interview questions are lined up

  • @suniltammineni1140
    @suniltammineni1140 3 роки тому +1

    Can you please make a video about advance lavel of exception handling questions

  • @kishoredanti5769
    @kishoredanti5769 3 роки тому +1

    Waiting for Part-2

  • @start1learn-n171
    @start1learn-n171 5 місяців тому +1

    Tq

  • @Ss_Sl
    @Ss_Sl 3 роки тому +1

    Yes we want advanced level please try a video

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      Sure will upload that soon

  • @user1994gms
    @user1994gms 2 роки тому +1

    Mentioned in comments.. do a video on it

    • @CodeDecode
      @CodeDecode  2 роки тому

      ua-cam.com/video/RS8oyAJHl2M/v-deo.html

  • @basavarajnv1017
    @basavarajnv1017 3 роки тому +2

    Thanks for the video madam🙏..do we have the 2nd part of the exception handling ??if not...could u plz make a 2nd part of it

    • @CodeDecode
      @CodeDecode  3 роки тому +1

      We well create second part soon 👍👍

  • @Bhavdip2011
    @Bhavdip2011 3 роки тому +1

    Give more videos on DS and Algorithms

    • @CodeDecode
      @CodeDecode  3 роки тому

      Sure once will complete this will start with data structures