What are different types of Exceptions?.

Answer Posted / solehah

Some of the common exceptions you may encounter are:

1. ArrayIndexOutOfBoundsException - Thrown when attempting to access an array with an invalid index value (either negative or beyond the length of the array).
2. ClassCastException - Thrown when attempting to cast a reference variable to a type that fails the IS-A test.
3. IllegalArgumentException - Thrown when a method receives an argument formatted differently than the method expects.
4. IllegalStateException - Thrown when the state of the environment doesn't match the operation being attempted, e.g., using a Scanner that's been closed.
5. NullPointerException - Thrown when attempting to access an object with a reference variable whose current value is null.
6. NumberFormatException - Thrown when a method that converts a String to a number receives a String that it cannot convert.
7. AssertionError - Thrown when a statement's boolean test returns false.
8. ExceptionInInitializerError - Thrown when attempting to initialize a static variable or an initialization block.
9. StackOverflowError - Typically thrown when a method recurses too deeply. (Each invocation is added to the stack.)
10. NoClassDefFoundError - Thrown when the JVM can't find a class it needs, because of a command-line error, a classpath issue, or a missing .class file

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better ascii or unicode?

555


What is array length?

495


What causes memory leak in java?

470


What is polymorphism and what are the types of it?

492


Explain the difference between collection api and stream api in java8?

499






What causes memory leaks in java?

477


Why stringbuffer is faster than string?

527


How many unicode characters are there?

543


Define immutable object?

573


How to add menushortcut to menu item?

557


Write a factorial program using recursion in java?

504


What do you mean Abstraction in java?

599


What is the difference between notify and notifyall method?

598


What does  mean in regex?

563


Java openings 3 - 5 years, Lnt Infotech. requirements - core java, J2ee, struts, hibernate Interview Date:- 19 March 2011 Time:- 9:00 AM to 12:00 Pm Interview Location - L & T Infotech, Manapakkam, Chennai Refererral PS NO:- 291649 (Please mention this when u fill the form only then u will be considered for interview) Documents Required:- Latest Resume, Photograph and last 3 payslips Mail me on vasan2211@gmail.com once u appear for interview

2847