GoConqr has a new look! Let us know what you think.

Mind map

Chapter 6

Enrique López Mata English

Map content

Chapter 6

  1. Exceptions

    • Event that alter program flow
    • Throwable supperclass
      • for all objects
      • java.lang.Throwable
        • java.lang.Exception(Checked Exceptions)
          • java.lang.RuntimeException (Unchecked Exceptions)
        • java.lang.Error
    • Error
      • something went wrong and your program should not attempt to recover from it.
        • Not okay for program to catch
        • No required to handle or declare
    • Exception(Checked)
      • Java requires code to
        • handle them
        • declare them in method
      • Okay to catch
    • RuntimeException(Unchecked)
      • unexpected but not necessarily fatal
        • Okay to catch
        • No required to handle or declare
    • keywords
      • throw
        • Tells Java to throw an exception
      • throws
        • might throw an exception
  2. Try Statement

    • Java use it to separate the logic
      • might throw an exception
        • from the logic to handle that exception.
    • Syntax
      • Try Block
        • If doesn't throw an exception
          • catch block doesn't run
        • Needs:
          • to have a catch or finally block
      • Catch Block
        • Exception handler
        • catch exception type must match the try exception error
        • must have a parenthesis
          • (exception_type identifier)
      • Finally Block
        • finally must be after a catch block
          • not viceversa
        • Run code at the end of the statement
          • Always executes whether or not an exception occurs
            • except if System.exit(0)
    • When a superclass is caught before a subclass
      • compiler error unreachable code
  3. Common Exception Types

    • Runtime Exceptions
      • thrown by JVM
        • ArithmeticException
          • when code attempt to divide by zero
        • ArrayIndexOutOfBoundsException
          • when code uses an illegal index to access an array
        • ClassCastException
          • when cast an exception to a subclass of which it is not an instance
      • thrown by programmer
        • IllegalArgumentException
          • indicate that a method has been passed an illegal argument
        • NullPointerException
          • when there is a null reference when an object is required
        • NumberFormatException
          • when try to convert a string to a numeric type and the string doesn't have an appropiate format
    • Checked Exceptions
      • thrown programmatically
        • IOException
          • when there's a problem reading or writing a file.
        • FileNotFoundException
          • when trying to reference an unexisting file
          • subclass of IOException
    • Errors
      • thrown by JVM
        • ExceptionInInitializerError
          • when static initializer throws an Exception and doesn't handle it
        • StackOverflowError
          • when a method calls itself to many times
        • NoClassDefFoundError
          • when a class code is available at compile time but not at runtime

Information

Description
Mind Map on Chapter 6, created by Enrique López Mata on 10/01/2019.
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?