1/49
Comprehensive practice flashcards covering Java I/O streams, JavaFX GUI architecture, controls, layout panes, event handling, and the Java Collections Framework.
What is stream I/O in Java?
Stream I/O is a mechanism that transfers a flow of data between a source (such as a keyboard, file, or network) and a destination (such as a console, file, or network).
How do Byte Streams and Character Streams differ in Java?
Byte Streams read and write data as 8-bit bytes for binary data (images, PDFs, audio) using base classes InputStream and OutputStream. Character Streams process text characters and handle encoding/decoding using base classes Reader and Writer.
What value is returned by the read() method of InputStream when the end of the stream is reached?
It returns −1.
What is the primary role of the File class in the java.io package?
The File class represents the path of a file or directory and provides methods to verify existence, inspect metadata, create, delete, and list directory contents.
What is the difference between the mkdir() and mkdirs() methods of the File class?
mkdir() creates a single directory, whereas mkdirs() creates the directory along with any necessary but nonexistent parent directories.
Which classes in java.io are used for serializing and deserializing Java objects?
ObjectOutputStream is used to serialize and write objects, and ObjectInputStream is used to read and deserialize them.
In JavaFX, what is a GUI control and which package contains most standard controls?
A control is an interactive, ready-made UI component placed inside a Scene to interact with the user; most controls reside in javafx.scene.control.
How do TextField and PasswordField differ in JavaFX?
TextField accepts a single line of unmasked plain text, whereas PasswordField masks the entered characters for privacy and security.
How does user selection differ between a CheckBox and a RadioButton?
A CheckBox represents an independent option that can be selected or cleared regardless of other checkboxes, whereas RadioButtons are grouped via a ToggleGroup to enforce mutually exclusive single-option selection.
What capability distinguishes ComboBox from ChoiceBox in JavaFX?
ComboBox supports text editing and custom user entries via setEditable(true), whereas ChoiceBox is a simpler choice control that does not support editable text entry.
How is multiple selection enabled in a JavaFX ListView?
By configuring its selection model using: list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
How are progress values passed to a JavaFX ProgressBar?
Progress is set as a double value ranging from 0.0 to 1.0, or set to ProgressBar.INDETERMINATE_PROGRESS to indicate unknown or ongoing progress.
Which class from the Java standard library does the JavaFX DatePicker control use to represent dates?
java.time.LocalDate
What are the distinct roles of getText(), getValue(), and isSelected() in JavaFX controls?
getText() retrieves displayed text as a String; getValue() retrieves the selected or entered object value (used by ComboBox, ChoiceBox, DatePicker); and isSelected() returns a boolean indicating whether a toggle or checkable control is active.
What is the primary function of a layout pane in JavaFX?
A layout pane is a container node that automatically positions and sizes child nodes (controls and shapes) and rearranges them during window resizing.
How does the base Pane class position child nodes compared to managed layout panes?
Pane provides free-form coordinate positioning using explicit coordinates (layoutX, layoutY, or relocate()), rather than automatically arranging nodes into rows, columns, or predefined regions.

Which JavaFX layout pane divides the interface into the five regions shown in the diagram?
BorderPane, which divides the available container space into Top, Bottom, Left, Right, and Center regions.
How does StackPane lay out its child nodes?
StackPane places child nodes on top of each other in a centered stack where later added children render above earlier children.
What is the difference between FlowPane and TilePane?
FlowPane wraps child nodes to the next line or column based on individual element sizes, whereas TilePane assigns each child node an identical, uniform tile width and height.
How does AnchorPane position its child nodes?
AnchorPane pins child nodes to the pane edges by specifying anchor offsets (top, bottom, left, or right), allowing nodes anchored on opposing edges to resize dynamically.
What is the root interface for the Java Collections Framework (excluding the Map hierarchy)?
java.util.Collection
What are the defining characteristics of the List interface in java.util?
List maintains insertion order, allows duplicate elements, allows null elements, and provides zero-based index access to elements.
Why are ArrayList iterators described as fail-fast?
If the list is structurally modified at any time after the iterator is created (except through the iterator's own add or remove methods), the iterator immediately throws a ConcurrentModificationException.
How does Vector differ from ArrayList?
Vector is a synchronized, legacy class that is thread-safe for individual operations, whereas ArrayList is unsynchronized and not thread-safe by default.
Which class does java.util.Stack extend, and what constructor does it provide?
Stack extends Vector and provides only a zero-parameter constructor.
How do HashSet, LinkedHashSet, and TreeSet differ regarding ordering and null elements?
HashSet provides no ordering guarantees and permits one null; LinkedHashSet preserves insertion order and permits one null; TreeSet maintains sorted order using a red-black tree and prohibits null elements under natural ordering.
How do the two sets of Queue methods (add/remove/element vs. offer/poll/peek) differ when an operation fails?
add(), remove(), and element() throw an exception on failure, whereas offer(), poll(), and peek() return a special value (false or null).
What internal data structure does ArrayDeque use, and are null values permitted?
ArrayDeque uses a resizable circular array, has no capacity restrictions, operates in amortized constant time, and strictly prohibits null elements.
What ordering does Java's default PriorityQueue implement, and does iteration display elements in sorted order?
It implements a min-heap where the smallest element has the highest priority; iteration does not guarantee sorted order, but polling always retrieves the head element with the highest priority.
Why is the Map interface considered separate from the Collection interface in Java?
Map manages key-value pairs where keys must be unique and map to at most one value, rather than managing a collection of individual elements.
How do HashMap, LinkedHashMap, and TreeMap differ in terms of ordering and lookup performance?
HashMap offers O(1) average lookup with no ordering guarantees; LinkedHashMap offers O(1) average lookup while preserving insertion order; TreeMap provides O(logn) operations while maintaining keys in sorted order.
What is the Properties class in java.util, and which class does it extend?
Properties is a synchronized class extending Hashtable used to manage application configuration settings as string-based key-value pairs that can be loaded from and saved to files.
How do Comparable and Comparator differ in Java?
Comparable defines natural ordering within the class itself via compareTo(T o), while Comparator defines external custom sorting logic via compare(T o1, T o2).
How does the BitSet class store data, and what does the cardinality() method return?
BitSet stores a sequence of bits (1 for true, 0 for false) packed efficiently into words, and cardinality() returns the total number of set bits (true bits).
How are Java assertions enabled when running an application from the command line?
Assertions are disabled by default and must be explicitly enabled using the -ea switch: java -ea
Which classes are used together in Java to support internationalization and localization (L10N)?
Locale (which identifies a specific language and country) and ResourceBundle (which loads localized key-value messages from .properties files).
Why is java.security.SecureRandom used instead of java.util.Random for security-sensitive applications?
java.util.Random uses a Linear Congruential Generator (LCG) algorithm and is not cryptographically secure, whereas SecureRandom provides cryptographically strong pseudorandom generation.
In JavaFX architecture, what is Prism and what rendering paths does it support?
Prism is the graphics rendering engine that handles render jobs using hardware acceleration (Direct3D, OpenGL) or falls back to software rendering if hardware is insufficient.
What are the primary responsibilities of the Glass Windowing Toolkit in JavaFX?
As the lowest level in the graphics stack, it connects JavaFX to native operating system services, manages windows, surfaces, timers, and manages the native event queue.
What is the function of the Quantum Toolkit in the JavaFX architecture?
It coordinates the rendering pipeline (Prism) and the native windowing system (Glass Windowing Toolkit) and enforces JavaFX threading rules.
What are the three main threads running in a standard JavaFX application runtime?
The JavaFX Application Thread (primary thread for UI construction and event handling), the Prism Render Thread (handles rendering separately from event dispatching), and the Media Thread (background synchronization of frames).
What are the three lifecycle methods of a JavaFX Application class, and which one is abstract?
init(), start(Stage primaryStage), and stop(); start(Stage primaryStage) is abstract and must be implemented by the application.
How do Stage and Scene differ in JavaFX?
A Stage represents the top-level operating system window, whereas a Scene represents the container for the visual content inside the stage and hosts the scene graph.
What are the two major phases of event delivery in the JavaFX event-dispatch chain?
The Capturing phase (where the event travels downward from the root node toward the target) and the Bubbling phase (where the event travels upward from the target back toward the root node).

In the provided JavaFX event-dispatch chain diagram, which node is designated as the event target?
The Circle node (the leaf node reached through the chain from VBox to HBox).
How do Event Filters and Event Handlers differ in JavaFX event handling?
Event Filters are registered via addEventFilter() and execute during the capturing phase (top-down), while Event Handlers are registered via addEventHandler() or setOnXxx() and execute during the bubbling phase (bottom-up).
What method on an Event object prevents further propagation along the event-dispatch chain?
event.consume();
What are the three core components of the JavaFX Media API and their roles?
Media represents the media resource/file; MediaPlayer controls playback behavior; and MediaView is the Node that renders the visual media within the scene graph.
What underlying engine powers JavaFX web browsing, and how do WebEngine and WebView divide responsibilities?
It is powered by the open-source WebKit engine; WebEngine manages web page loading and browsing logic, while WebView is a Node that renders HTML content in the scene.
At what three stages can user input validation be performed in a JavaFX application?
Validation while entering data (via EventFilter), validation when focus leaves a field (focus-based validation), and validation when the user clicks the submit button.