Exceptions & File I/O:Read Flashcards
compile-time error
occurs when there is a syntactical error or the compiler identifies code that cannot execute
run-time error
occurs while the program is executing when it is asked to access memory that is inaccessible or perform an operation of which it is not capable
Run-time errors often result in an Exception
Throwables
Exceptions and Errors
Errors
sed by the JVM to indicate errors that are associated with the runtime environment, such as running out of memory or other resources. Errors occur only at runtime and it is not possible for an application recover from these errors
Exceptions
anomalous situations that occur while a program is executing
Checked Exceptions
must be caught with a try…catch.
When calling a method that has a checked exception then the possible exception it can throw must either be caught and dealt with using a try…catch or the method calling it must itself throw an exception of that type.
Runtime Exceptions
can be thrown from any method and do not have to caught with a try…catch.
Exception Handling
dealing with unexpected problems in an application so the program does not crash.
Stack Trace
details about what happened and where it occurred in the code
Try…Catch Block
Risky code is surrounded with a try…catch. The try identifies a block of code that may cause an exception, and the catch block identifies a block of code to run if an exception occurs. When an exception occurs in the try, all following lines of code are skipped and the catch is immediately executed
Throw and Throws
Exceptions can be thrown manually using the throw keyword. The throw keyword is a statement of code. throw new MyException();
A method may indicate that it can thrown a checked exception using the throws keyword. The throws keyword is part of the method signature.
public void myMethod() throws MyException
Call Stack.
When an Exception is thrown it is passed up through each level of the call stack. At each level it can be caught and handled by a try…catch().
File Modes
Indicates a File d Indicates a directory l Indicates a Link -rwxrwxrwx R - Read W - write X - execute
-RWXrwxrwx
r has read permission w has write permission x has execute permission - does not have this permission for the slot it is in. First Group is for the Owner of the File
-rwxRWXrwx
Second Group is for users that are members of the same user group as the owner of the file