面试题 |
您所在的位置:网站首页 › 什么什么当问什么什么写出五个 › 面试题 |
java提供了两种异常机制。
一种是运行时异常(RuntimeException), 一种是受检异常(Checked Exception)。 受检异常:我们经常遇到的IO异常及sql异常就属于检查式异常。对于这种异常,java编译器要求我们必须对出现的这些异常进行catch,面对这种异常要么throws,要么catch 运行时异常:我们可以不处理。当出现这样的异常时,总是由虚拟机接管。 RuntimeExecption在java.lang包下 下面是由java虚拟机提供的运行时异常AnnotationTypeMismatchException, ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, EnumConstantNotPresentException, EventException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IncompleteAnnotationException, IndexOutOfBoundsException, JMRuntimeException, LSException, MalformedParameterizedTypeException, MirroredTypeException, MirroredTypesException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NoSuchMechanismException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, RejectedExecutionException, SecurityException, SystemException, TypeConstraintException, TypeNotPresentException, UndeclaredThrowableException, UnknownAnnotationValueException, UnknownElementException, UnknownTypeException, UnmodifiableSetException, UnsupportedOperationException, WebServiceException 5种常见异常:ClassCastException(类转换异常) IndexOutOfBoundsException(数组越界) NullPointerException(空指针) ArrayStoreException(数据存储异常,操作数组时类型不一致) 还有IO操作的BufferOverflowException异常 Java异常Error和Exception的区别:https://blog.csdn.net/iblade/article/details/78196016 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |