JavaFX Basics
Event-Driven Programming
Data Structures & ADTs
Binary Trees & Heaps
HashMaps, TreeMaps, and Sets
100

What class must all JavaFX applications extend?

Application

100

What interface handles JavaFX events like button clicks?

EventHandler<ActionEvent>

100

What data structure follows FIFO (First-In, First-Out)?

Queue

100

In a binary tree, what is a node with no children called?

Leaf Node

100

What data structure provides O(1) lookup time for unique values?

HashSet

200

What JavaFX method initializes the user interface?

start(Stage stage)

200

What is the difference between using a lambda vs. an anonymous class for event handling?

Lambda is shorter and more readable.

200

What data structure follows LIFO (Last-In, First-Out)?

Stack

200

What property distinguishes a Binary Search Tree (BST) from a regular Tree?

Left subtree has smaller values; right has larger values.

200

What is the key difference between HashMap and TreeMap?

HashMap is unordered; TreeMap is sorted.

300

What is the function of a Scene in JavaFX?

Holds UI components (nodes)

300

What pattern is used in JavaFX to notify objects of changes?

Observer Pattern

300

What is the main advantage of using Linked Lists over Arrays?

Faster insertions and deletions at the head/tail.

300

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)

300

What tree structure does TreeSet use internally?

Red-Black Tree

400

What JavaFX class represents a window, and how do you initialize & display it?

stage.setScene(scene);

stage.show();

400

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!");

    }

});

400

What fields does a link list store, and what data types are they?

head (Node), Tail (Node), Size (int)

400

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 

400

How do you check if a HashMap contains a key? What about if it contains a value?

.containsKey(), .containsValue()
500

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);

500

What are the three components of the MVC Pattern, and an example of each?

Model, View, Controller

500

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

...
        } 

}

500

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);

    }

}

500

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