Tuesday 3 March 2020

Top 11 interview questions on Exceptions handling in Java for SDET/Developers/Automation Testing?Exception handling in Java

This post is completely on theory, but I will post another one with example for each exception mentioned below:
  • Arithmetic Exception: 
It is thrown when an exceptional condition has occurred in an arithmetic operation.

  • ArrayIndexOutOfBoundException: 

 It is thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.

  • ClassNotFoundException:

 This Exception is triggered when we try to access a class whose definition is not found.

  • FileNotFoundException:

This Exception is thrown when a file is not accessible or does not open. Quite common

  • InterruptedException: 

 It is triggered when a thread is waiting , sleeping , or doing some processing , and it is interrupted.


  • NoSuchMethodException: 

It is thrown when accessing a method which is not found.

  • NullPointerException: 

 This exception is appeared when referring to the members of a null object.

  • NumberFormatException:

 This exception is thrown when a method could not convert a string into a numeric format.

  • StringIndexOutOfBoundsException:

It is thrown by String class methods to indicate that an index is either negative than the size of the string.

  • What is checked and unchecked exception?

1) Checked Exception:
The classes which directly inherit Throwable class except the RuntimeException and Error are called as checked exceptions e.g. IOException, SQLException etc. Those exceptions are checked at compile-time.
2) Unchecked Exception:
The classes which inherit RuntimeException are known as unchecked exceptions e.g. ArithmeticException, ArrayIndexOutOfBoundsException ,NullPointerException etc. 
Unchecked exceptions are not checked at compile-time, but they are checked at runtime.

  • What is Error?

Error is not recoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc.



Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122

Entire course content can be found below:  COURSE CONTENTCheck below link for question and answers with code:
 

No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...