What class must all JavaFX applications extend?
Application
What interface handles JavaFX events like button clicks?
EventHandler<ActionEvent>
What data structure follows FIFO (First-In, First-Out)?
Queue
In a binary tree, what is a node with no children called?
Leaf Node
What data structure provides O(1) lookup time for unique values?
HashSet
What JavaFX method initializes the user interface?
start(Stage stage)
What is the difference between using a lambda vs. an anonymous class for event handling?
Lambda is shorter and more readable.
What data structure follows LIFO (Last-In, First-Out)?
Stack
What property distinguishes a Binary Search Tree (BST) from a regular Tree?
Left subtree has smaller values; right has larger values.
What is the key difference between HashMap and TreeMap?
HashMap is unordered; TreeMap is sorted.
What is the function of a Scene in JavaFX?
Holds UI components (nodes)
What pattern is used in JavaFX to notify objects of changes?
Observer Pattern
What is the main advantage of using Linked Lists over Arrays?
Faster insertions and deletions at the head/tail.
What is the time complexity of inserting an element in a balanced BST? What about the worst case for an unbalanced tree?
O(log N),O(N)
What tree structure does TreeSet use internally?
Red-Black Tree
What JavaFX class represents a window, and how do you initialize & display it?
stage.setScene(scene);
stage.show();
How do you code an event handler for a button?
Button button = new Button("Click Me!");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Button clicked!");
}
});
What fields does a link list store, and what data types are they?
head (Node), Tail (Node), Size (int)
What makes a heap different from a BST? Also what is stored the root of a heap?(HINT: there are two answers here!)
It re-orders (swaps) the nodes to remain balanced. The smallest (Min-Heap) or largest (Max-Heap) value
How do you check if a HashMap contains a key? What about if it contains a value?
How do you initialize a vertical group of labels?
VBox vbox = new VBox();
Label label1 = new Label("Label1!");
Label label2 = new Label("Label2!");
vbox.getChildren().addAll(label1, label2);
What are the three components of the MVC Pattern, and an example of each?
Model, View, Controller
What would you code to allow an object to be iterated using for-each?
class MyCollection<T> implements Iterable<T> {
.....
@Override
public Iterator<T> iterator() {
return new MyIterator();
}
private class MyIterator implements Iterator<T> {
private int currentIndex = 0;
@Override
public boolean hasNext() {
...
}
@Override
public T next() {
...
}
}
How do you define a custom sorting method for a data structure (like a heap!)
public class Heap implements Comparable<Heap> {
...
@Override
public int compareTo(Heap other) {
return Integer.compare(this.value, other.value);
}
}
Fill out the time complexity & use-case for each data structure:
Hash Set
TreeSet
Hash Map
Tree Map
Hash Set
O(1)
Fast unique elements
TreeSet
O(log N)
Unique sorted elements
Hash Map
O(1)
Fast key-value pairs
Tree Map
O(log N)
Sorted key-value pairs