Java Written Exam 3 Flashcards

1
Q

checked exceptions

A

must be caught or declared

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

unchecked exceptons

A

don’t have to be caught or declared

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

class invarient

A

is an assertion about an object’s state that is true throughout the lifetime of the object
eg no bankAccount object’s balance can be negative

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

precondition

A

Something you assume to be true when the method is called

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

postcondition

A

something you promise to be true when your method calls

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

how are pre/post conditions documented?

A

as comments

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

common exceptions

A

illegalArgumentException, ArithetricException, IllegalStateException, YourCustomeExceptions
(and FileNotFound exceptions I would add)

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

junit test for exceptions

A

assertThrows, assertDoesNotThrow

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

syntax junit exceptions

A

”() -> <expression>" , This is a "lambda" - an anonymous, inline function definition</expression>

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

token based processing

A

practice of processing input token by token (ie one word at a time or one number at a time)

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

token

A

unit of user input, separated by a delimited

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

scanner token based methods

A

next(), nextInt(), nextFloat()

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

line based scanner methods

A

nextLine()

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

printing out to file syntax

A

PrintStream <name> = new PrintStream (new File ("results.txt");</name>

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

printStream details

A

if the given file does not exist, it is created.
If the given file already exists it is overwritten
Output appears to file, not console
Do not open the same file for both reading (Scanner) and writing (PrintStream) at the same time

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

printStream exceptions

A

You might not have permission to write to the directory
You might be locked because another file is using it
need a throws clause

17
Q

generic

A

Generic class is a type in Java that is written to be a placeholder for another type

<T>
T
</T>