Lecture 3: Control Flow and Error Handling Flashcards

1
Q

What is the difference between usual approach and event driven computing?

A

Usual: Start > hits well defined branch and loop points>Demand user inputs at points>proceeds to end> stops
Event driven computing: Start> set up complete > enter a main loop> loop around waiting for events then triggering code when they occur.

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

why use switch statements for flow control(3)?

A
  • Simple, many frameworks allow you to write part of the code
  • Switches are easy to extend
  • Matching multiple events to one piece of code is easy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

StackOverflowException

A

the call stack cannot grow any larger

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

OutOfMemoryException

A

the system has run out of memory

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

NullReferenceException

A

when an attempt is made to access an attribute/operation of an object when the reference is set to null

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

ArgumentException

A

one or more arguments were invalid

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

FileNotFoundException

A

specified file does not exist

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

InvalidCastException

A

a data type casting is not valid(usually because the types are unrelated)

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

DivideByZeroException

A

attempt made to divide by zero

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

IndexOutOfRangeException

A

array index is out of range

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

OverflowException

A

converting a value, such as with the Convert object, results in a loss of data

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

What are the Methods for error handling(2)?

A

Parse() and TryParse()

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

What are Exceptions?

A
  • when an error is detected an object is created with information about the error
  • object is thrown directly to the error handling routine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the three parts of a try catch finally block?

A
  • try block contains code that may throw an exception
  • catch blocks handle different exceptions that are thrown(0 or more)
  • finally block executes the code regardless of exception or not
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why use a Custom Exception?

A

often the exception classes will not be suitable so we create our own.

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