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
What is the default size of set in java?
Does java arraylist maintain insertion order?
Name some OOPS Concepts in Java?
How can a gui component handle its own events in java programming?
Tell me are there implementations for sorting and searching in the java libarary?
What do you mean by platform independence?
Does java isempty check for null?
What is meant by oops concept in java?
Can we use both this () and super () in a constructor?
Can we convert stringbuilder to string in java?
What is the use of static methods?
What is bifunction in java?
Can we make the abstract methods static in java?
What are some characteristics of interference class?
Which collection does not allow duplicates in java?