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

  Рет қаралды 204,489

Code Decode

Code Decode

3 жыл бұрын

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/u...
Course Description Video :
yt.openinapp.c...
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 : www.youtube.co...
Linkedin : / codedecodeyoutube
Instagram : / codedecode25
--------------------------------------------------------------------------------------------------------------------------------------
#ExceptionHandlingInterviewQuestionsInJava
#ExceptionHandlingHandlingInterviewQuestionsForExperiencedInJava
#javainterviewquestionsandanswers #codedecode

Пікірлер: 270
@kanchanyasita8272
@kanchanyasita8272 3 жыл бұрын
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.
@aasimahsan6167
@aasimahsan6167
great explanation cleared all the doubt and also gained confidence
@divsreviews2860
@divsreviews2860 Жыл бұрын
Hello Mam, You made Java Developer's life easy,, Thank you so much for your dedication towards Java Developer ✌️🙏🏻.. God Bless you 😊
@sandhyarajkumar8597
@sandhyarajkumar8597 2 жыл бұрын
Your explanation is amazing...to the point...understandable...keep making such videos...😊
@sougatabanerjee8832
@sougatabanerjee8832 Жыл бұрын
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.
@reddaboinavasista4166
@reddaboinavasista4166
Very Underrated youtuber. Deserves more subscribers.
@prisha1729
@prisha1729 3 жыл бұрын
Please upload videos on advance exception handling and try with reassures as well. Your videos are great for interview preps. Thanks
@aaaaaaaa3811
@aaaaaaaa3811 3 жыл бұрын
very nice and awesone explanation.👌👌👌....keep doing more n more videos like this mam.....hatsoff to u...
@mohantyfamily1521
@mohantyfamily1521 2 жыл бұрын
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.
@arlynsneha5052
@arlynsneha5052 3 жыл бұрын
Wonderful video mam 🤩🤩🤩🤩🤩. Mam plz do intermediate exception handling questions
@praveenraj3721
@praveenraj3721 3 жыл бұрын
this video is very helpful and as you said you need to extend this video to intermediate and advanced level.
@mnishi2780
@mnishi2780 3 жыл бұрын
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
@kalpeshmahagaonkar2145
@kalpeshmahagaonkar2145 3 жыл бұрын
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.
@rahulnigam7529
@rahulnigam7529 2 жыл бұрын
@10.36 - question must prepare , its always ask in interview . Nice video
@chenchaiahmalli6234
@chenchaiahmalli6234 3 жыл бұрын
Very nice and clear explanation Mam...Its very helpful...Keep it up.
@rudrarajusowmya8943
@rudrarajusowmya8943 2 жыл бұрын
Firstly thanks for this tutorial. Can you cover the Intermediate and Advance level of questions also. It will be helpful
@Hare_Krishna143
@Hare_Krishna143 2 жыл бұрын
Such helpful content!!! Appreciate
@vibhorgoel4614
@vibhorgoel4614 3 жыл бұрын
Outstanding work done... Watching all your videos for learning. Expecting more soon.. Good Job
@allancmm
@allancmm 2 жыл бұрын
Since Java 8, it's possible to use try whitout expliciting using catch. When creating object from classes that implement AutoCloseable:
@prithvisingh40
@prithvisingh40 3 жыл бұрын
Advanced exception handling will be helpful
Harley Quinn's desire to win!!!#Harley Quinn #joker
00:24
Harley Quinn with the Joker
Рет қаралды 7 МЛН
CHOCKY MILK.. 🤣 #shorts
00:20
Savage Vlogs
Рет қаралды 27 МЛН
SPILLED CHOCKY MILK PRANK ON BROTHER 😂 #shorts
00:12
Savage Vlogs
Рет қаралды 44 МЛН
Top 30 JAVA Interview Questions and Answers for Beginners
1:25:45
Interview Happy
Рет қаралды 14 М.
Exception Handling in Java
56:53
Telusko
Рет қаралды 33 М.
19. Exception Handling in Java with Examples
1:14:41
Concept && Coding - by Shrayansh
Рет қаралды 17 М.
Java Exception Handling Tutorial
11:39
Keep On Coding
Рет қаралды 81 М.
Compilers, How They Work, And Writing Them From Scratch
23:53
Adam McDaniel
Рет қаралды 146 М.
Harley Quinn's desire to win!!!#Harley Quinn #joker
00:24
Harley Quinn with the Joker
Рет қаралды 7 МЛН