What type of exception is a ClassCastException and when does it occur?
A ClassCastException is a Runtime Exception and it occurs when an object cast into another object that the object isn't.
What are the four types of I/O?
Reader and Writer and InputStream and OutputStream.
What is BFS always guaranteed to find?
The shortest path.
What is the vocab term to describe removing invalid configurations to improve runtime?
Will you have to know how a GUI tree thing works on the exam?
Definitely.
Stage -> Scene -> Node
Pretty much every javaFX item extends Node.
- Pane, Button, Text, ImageView <- these are the ones yall use in this course
- Panes have more nodes in them.
- Keep going down the tree until all leaf nodes have nodes that aren't panes
What is the difference between a Runtime Exception and a Checked Exception?
A runtime exception doesn't have to be caught or thrown explicitly in the syntax and is an Unchecked Exception.
What is a decorator pattern?
When an object takes in another object to expand its functionality.
What data structure does a BFS use?
A Queue
What are the two parts of the getSucessors function?
1. Deep copying all information into a new configuration
2. Modifying the information in the new configuration
What method is used to run the GUI and what order of methods are called after that?
Application.launch(args);
init, start, close
What is the syntax to throw an Exception with the message "sup".
Write the line of code to create a PrintWriter to System.out. If you can also make it so the PrintWriter auto flushes when it encounters a new line then you get double points.
PrintWriter pw = new PrintWriter(System.out, true);
Is a binary search tree a graph? If so, what kind of graph?
Directed Acyclic Graph
Time complexity of BFS, DFS, and Backtracking
Backtracking: O(2^N)
Backtracking: O(|S|^N) where S is the set of successors for each node.
Which methods do you call to set the elements of a BorderPane?
setTop, setLeft, setCenter, setRight, setBottom
What is the difference between an Error and an Exception?
An Error shouldn't normally be handled. They can be handled just like Exceptions, except they probably shouldn't because it is very difficult to recover from and it isn't a hundred percent sure when they occur.
What are two ways in class to represent a graph?
Adjacency List, Adjacency Matrix, Edge List
What are the 3 functions that the Configuration Interface declares?
boolean isValid();
Collection<Configuration> getSucessors();
boolean isGoal();
Write the code that when a button is clicked then the function runButton is called.
button.setOnAction(e -> {
runButton();
});
What is the output of this function?
Why did you learn IO and exceptions in the same week?
IOExceptions are often thrown when working with IO and IOExceptions are Checked Exceptions. It is impossible to learn IO without first learning Checked Exceptions.
Run a BFS and DFS algorithm on this graph starting at node d. When visiting a neighbor go in alphabetical order.
BFS: d, c, e, a, b, f, g
DFS: d, c, a, b, f, g, e
Daily Double:
What is the minumum amount of lines of code that needs to be changed to turn this code into DFS. Also for that line what is the change that needs to be made?
2 lines of code:
Line 189: Stack<NodeType> toGetNeighbors = new Stack<>();
Line 193: NodeType current = toGetNeighbors.pop();
Which tier usually creates the model tier and why?
The View Tier, because it needs to add itself as an Observer.