Exception handling Interview Questions and Answers in Java | Code Decode | Live Demo | Part 2

preview_player
Показать описание
Experienced and Freshers both candidate can refer this video of Code Decode Exception handling Interview Questions and Answers

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

This video covers exception handling frequently asked interviews and answers with Live code demos . It covers Chained exceptions, exception propagation such concepts.

Lets understand this with an example. Where the normal flow of your java application goes like this. You send a http request for a resource to controller.
Controller handles it and send to Service where business logic is written which in turn gives inputs to DAO layer If database interaction is needed. Then finally data is Added or fetched to or from data base back to Same flow from DB to DAO to Service/ business layer to controller which sends response to UI and u get the data form the DB or update the data in DB.

Now Consider a situation where Database exception occurs and u need to tell this to user. You can see multiple layer in between. How to preserve the original exception when it propagates across multiple logical layers in a program?
Answer is through Exception Chaining.
Here Database throws SQLException. Which is caught by DAO class.
DAO class throws DAOException which is caught by Catch block in Service class.
Service class throws the catched DAO exception as ServiceException which in turn is caught by controller .
Controller will now handle it appropriately and send the user friendly message to UI to be shown.
The printed exception stack trace reveals an exception propagates from the SQL / DB layer up to the Controller layer.
This is called exception propagation which helps in debugging process.

Chained Exceptions allows to relate one exception with another exception, i.e one exception describes cause of another exception.
Methods Of Throwable class Which support chained exceptions in java :
getCause() method :- This method returns actual cause of an exception
initCause(Throwable cause) method :- This method sets the cause for the calling exception.

The initCause() method of Throwable class is used to initialize the cause of the this Throwable with the specified cause passed as a parameter to initCause(). Actually, the cause is the throwable that caused this throwable Object to get thrown when an exception occurs. This method can be called only once. Generally, This method is called from within the constructor, or immediately after creating the throwable.

Chained exception helps during exception handling. you get the real cause of exception

Subscriber and Follow Code Decode

#codedecode #exceptionhandling #javainterviewquestions
Рекомендации по теме
Комментарии
Автор

You are just savior for the developers like me who sticks to a company for a long time only because of not having regular touch with techinical skills. Mam, you are just awesome in explaining things more crisp and clearer.
You must deserve more and more subscribers and I just want you to thank in person as I watched most of your videos day and night that helps me to crack interviews in reputed organizations like harman etc.
Really loved your work to the core and no thank you will pay the value for your amazing work. WE ARE HERE TO SUPPORT YOU 🙌 KEEP GOING MAM🤩

pradeepn
Автор

Please make 3rd part of this exception handling series. We are waiting for 3rd part. These videos are very helpful for all the java developers. Thanks😊

abhishekatri
Автор

Ever since I started watching your videos, I have been recommending it to anyone who is in the process of job search. Love the way you keep things to the point and technical enough for anyone to easily understand and follow... Please continue the good work and help many more like me to find new jobs.
Thanks again 💐

yogeshatc
Автор

Hello Ma'am, I recently started watching your videos. And I really loved your way of explaining concepts like a tutor. Now I am going to follow your series for all the skillset that is needed for all the preparation of interviews. Could you please reply if you have created its sequence video also so please provide the link. for covering the remaining concepts of exception handling like exit try block scenarios, try with resources and whatever the concepts you were mentioning in the end of this video. And it would be better if you create short playlist for these topics like multithreading, garbage collection.

Keep helping with your videos Ma'am. Thank you 🙂

rashmipal
Автор

Yes!! Please create more videos on spring and hibernate. Good knowledge sharing video.

akashsaha
Автор

Really great video. Can you please share the next videos as you have mentioned.

tejasvitarathore
Автор

Sure please upload more of videos on exception handling... It wld be really helpful

PriyankaPawar-slgl
Автор

Great videos, I have been suggesting my friends to go through your videos for easy understanding . So please create sequence :)

shruthishru
Автор

Please please please create more videos on advance questions of exception handling . Please
I have been referring to my friends to watch and like who ever is working in java or searching a job in java

urmitabhaumik
Автор

Please create video on different cases of parent and derived class method behaviour when either is throwing exception and if we can increase or reduce exception

naadhsharyticha
Автор

I just want to know from where this energy to you ma'am 🙏 really great way of explaining things 😊

seemah
Автор

I am trying to insert audit log of the exception in catch block when exception occur in try block but it is not inserting into db and it is giving Nosuchelement exception from catch block

saigouni
Автор

Thanks 👍. Please continue videos on the topic

sourabhjinde
Автор

Mam please cover all other sections of exception handling also.
We are eagerly waiting for it....
Thank you in advance 🙂

RockMB
Автор

You shown some questions in last part of the video. But they are not covered 😢

kshitiz
Автор

Mam make more such videos for exception handling like try with resource, custom exception

sandeepmajhi
Автор

Great video. Please create customized exception video

mohitsoni
Автор

Please cover all other part which were remaining please 😊

vishwaratnasrivastava
Автор

Hi madam can you please create an video how anonymous inner class is used while using lamda expression like when we use lamda what happens internally?

challaprashanthreddy
Автор

Please create more videos in order to cover whole exception handling section .

muditranjan