Exceptions & File I/O:Read Flashcards

1
Q

compile-time error

A

occurs when there is a syntactical error or the compiler identifies code that cannot execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

run-time error

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Throwables

A

Exceptions and Errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Errors

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Exceptions

A

anomalous situations that occur while a program is executing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Checked Exceptions

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Runtime Exceptions

A

can be thrown from any method and do not have to caught with a try…catch.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Exception Handling

A

dealing with unexpected problems in an application so the program does not crash.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Stack Trace

A

details about what happened and where it occurred in the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Try…Catch Block

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Throw and Throws

A
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Call Stack.

A

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().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

File Modes

A
Indicates a File
      d     Indicates a directory
      l      Indicates a Link
-rwxrwxrwx
R - Read
W - write
X - execute
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

-RWXrwxrwx

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

-rwxRWXrwx

A

Second Group is for users that are members of the same user group as the owner of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

-rwxrwxRWX

A

Third Group is for all other users

17
Q

File Operations

A
exists()
isDirectory()
isFile()
getName()
getAbsolutePath()
mkdir()
createNewFile()
18
Q

exists()

A

boolean - does the file or directory exist

19
Q

isDirectory()

A

boolean - returns true if the path points to a directory

20
Q

isFile()

A

boolean - returns true if the path points to a file

21
Q

getName()

A

Returns the name of the file or directory

22
Q

getAbsolutePath()

A

Returns the absolute path of the file or directory

23
Q

mkdir()

A

Creates a new directory in the specified location

24
Q

createNewFile()

A

Creates a new File in the specified location